0

I am trying to setup Webpack following this tutorial, but I get an error when I try to run the command

npm run build

Node: v8.10.0

Ubuntu: 18.04

Error

sh: 1: Webpack: not found
npm ERR! Linux 4.15.0-54-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! webpacks@1.0.0 build: `Webpack --mode development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the webpacks@1.0.0 build script 'Webpack --mode development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webpacks package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     Webpack --mode development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs webpacks
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls webpacks
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/webpacks/npm-debug.log

Log

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@3.5.2
3 info using node@v8.10.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle webpacks@1.0.0~prebuild: webpacks@1.0.0
6 silly lifecycle webpacks@1.0.0~prebuild: no script for prebuild, continuing
7 info lifecycle webpacks@1.0.0~build: webpacks@1.0.0
8 verbose lifecycle webpacks@1.0.0~build: unsafe-perm in lifecycle true
9 verbose lifecycle webpacks@1.0.0~build: PATH: /usr/share/npm/bin/node-gyp-bin:/var/www/html/webpacks/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
10 verbose lifecycle webpacks@1.0.0~build: CWD: /var/www/html/webpacks
11 silly lifecycle webpacks@1.0.0~build: Args: [ '-c', 'Webpack --mode development' ]
12 info lifecycle webpacks@1.0.0~build: Failed to exec build script
13 verbose stack Error: webpacks@1.0.0 build: `Webpack --mode development`
13 verbose stack spawn ENOENT
13 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:17:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid webpacks@1.0.0
15 verbose cwd /var/www/html/webpacks
16 error Linux 4.15.0-54-generic
17 error argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 error node v8.10.0
19 error npm  v3.5.2
20 error file sh
21 error code ELIFECYCLE
22 error errno ENOENT
23 error syscall spawn
24 error webpacks@1.0.0 build: `Webpack --mode development`
24 error spawn ENOENT
25 error Failed at the webpacks@1.0.0 build script 'Webpack --mode development'.
25 error Make sure you have the latest version of node.js and npm installed.
25 error If you do, this is most likely a problem with the webpacks package,
25 error not with npm itself.
25 error Tell the author that this fails on your system:
25 error     Webpack --mode development
25 error You can get information on how to open an issue for this project with:
25 error     npm bugs webpacks
25 error Or if that isn't available, you can get their info via:
25 error     npm owner ls webpacks
25 error There is likely additional logging output above.
26 verbose exit [ 1, true ]

package.json

{
  "name": "webpacks",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "Webpack --mode development"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.39.3"
  }
}

I've tried to install webpack globally with npm i webpack -g as suggested here but it did not help

I have successfully bundled a main.js file which got saved in the dist folder, this happend after i ran the webpack-cli command, if i make changes to the bundled files they will first bundle if i run webpack-cli again

Javaish
  • 179
  • 14

1 Answers1

1

You have to change webpack command in package.json to be small case instead of camel case, you are writing Webpack in build script,

    "build": "webpack --mode development"
Yasser Mas
  • 1,652
  • 1
  • 10
  • 14