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

6 Answers

Try using: npm i -g webpack-cli.

Here is the official issue on github:

2

Link globally installed package to your project

npm link webpack-cli
1

This solved the problem for me

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

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

I had a similar error. For me the answer was to ensure that the whole path to my project is free of spaces, ampersands(&) or any other weird characters.

If you are using Yarn instead NPM to run Webpack globally, you can install webpack using the following commands:

yarn global add webpack

and or

yarn global add webpack-cli

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest