Noubar Hanno
Noubar Hanno

Reputation: 21

sh: webpack command not found

i'm new to Webpack and i was follow their documentation https://webpack.js.org/guides/getting-started/

in order to structure my first simple code and build the same using webpack

in the last section where i have to add build command to scripts in package.json

    {
  "name": "webpack-demo",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack --config webpack.config.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.20.2",
    "webpack-cli": "^3.1.2"
  },
  "dependencies": {
    "lodash": "^4.17.11"
  }
}

and i run npm run build i got the error

npm run build

> [email protected] build /Users/test/Desktop/Devolopment/webpack-demo
> webpack --config webpack.config.js

sh: webpack: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: `webpack --config webpack.config.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/test/.npm/_logs/2019-03-20T04_11_16_661Z-debug.log

could some one help me why, keep in mind that i followed the documentation exactly with the same packages version used in the documentation

best regards

Upvotes: 1

Views: 6177

Answers (1)

Noubar Hanno
Noubar Hanno

Reputation: 21

I have realized that I had to install webpack and webpack-cli globally,

now it's working fine.

Thank you so much.

Upvotes: 1

Related Questions