Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module 'webpack-cli'

I want to make es6 into my project so I used this tutorial this tutorial and when i try to write 'webpack' in cmd I get the error

    Done in 8.99s.
{ Error: Cannot find module 'webpack-cli'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at runCommand.then.result (C:\Users\adirz\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14)
    at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NOT_FOUND' }

package.json

   {
  "name": "functions",
  "scripts": {
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "~5.12.0",
    "firebase-functions": "^1.0.1"
  },
  "devDependencies": {
    "ts-loader": "^4.2.0",
    "typescript": "^2.5.3",
    "webpack": "^4.5.0",
    "webpack-cli": "^2.0.14",
    "webpack-node-externals": "^1.7.2"
  },
  "private": true
}

my folder structure

enter image description here

like image 949
Manspof Avatar asked Apr 16 '18 10:04

Manspof


People also ask

Can not find module Yargs?

To solve the error "Cannot find module 'yargs'", make sure to install the yargs package by opening your terminal in your project's root directory and running the following command: npm i yargs . If you use TypeScript, install the typings by running npm i -D @types/yargs .

Where is my webpack config JS?

The webpack configuration file webpack. config. js is the file that contains all the configuration, plugins, loaders, etc. to build the JavaScript part of the NativeScript application. The file is located at the root of the NativeScript application.


4 Answers

Try using: npm i -g webpack-cli.

Here is the official issue on github: https://github.com/webpack/webpack-cli/issues/191

like image 89
Anita Fronczak Avatar answered Oct 08 '22 01:10

Anita Fronczak


Link globally installed package to your project

npm link webpack-cli
like image 26
willdonner Avatar answered Oct 08 '22 01:10

willdonner


This solved the problem for me

sudo chown -R $USER /usr/local/lib/node_modules
npm i -g webpack-cli

https://flaviocopes.com/npm-fix-missing-write-access-error/

like image 2
Mohamad Hamouday Avatar answered Oct 08 '22 01:10

Mohamad Hamouday


The problem for me it was that I was not using 'sudo' permissions. If you are using linux based system try typing sudo npm i -g webpack-cli

like image 1
Rudr Thakur Avatar answered Oct 08 '22 01:10

Rudr Thakur