WEBPACK commands do not work

Asked

Viewed 327 times

1

I installed the webpack with the command npm install webpack -g , but when I try to use the webpack -h or any other of that problem

> PS C:\Users\renan\Desktop\Wchat> webpack -h The CLI moved into a
> separate package: webpack-cli Would you like to install webpack-cli?
> (That will run npm install -D webpack-cli) (yes/NO)

After yes, the following error appears

PS C:\Users\renan\Desktop\Wchat> webpack -h
The CLI moved into a separate package: webpack-cli
Would you like to install webpack-cli? (That will run npm install -D webpack-cli) (yes/NO)yes
npm WARN deprecated [email protected]:   Thanks for using Babel: we recommend using babel-prese
t-env now: please read babeljs.io/env to update!
npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
updated 1 package in 45.313s
{ Error: Cannot find module 'webpack-cli'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at runCommand.then.result (C:\Users\renan\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7) code: 'MODULE_NOT_FOUND' }

With this error I am useless to use the commands webpack , Someone could help me solve ?

Here is the package.json

{
  "name": "trabalhofinal",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ejs": "^2.5.9",
    "express": "^4.16.3",
    "simple-peer": "^9.1.1"
  },
  "devDependencies": {
    "webpack": "^4.6.0",
    "webpack-cli": "^2.1.2",
    "webpack-dev-server": "^2.7.1"
  },
  "description": ""
}

After setting the webpack command the following error appeared when trying to make a Bundle.js

webpack ./src/app.js ./public/bundle.js
Hash: 0ad17ada6fbd759751dd
Version: webpack 4.6.0
Time: 629ms
Built at: 2018-05-01 01:45:09
 1 asset
Entrypoint main = main.js
[0] ./src/app.js 23 bytes {0} [built]
[1] multi ./src/app.js ./public/bundle.js 40 bytes {0} [built]

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/

ERROR in multi ./src/app.js ./public/bundle.js
Module not found: Error: Can't resolve './public/bundle.js' in 'C:\Users\renan\Desktop\TrabalhoFinal'
 @ multi ./src/app.js ./public/bundle.js
PS C:\Users\renan\Desktop\TrabalhoFinal>
  • 1

    Well, as far as I can tell, he’s been installed. Edith your question and place the contents of the file package json. .. If I am not mistaken, to install a global package, use the command npm install -g pacote and not npm install pacote -g That could be where the problem is

  • I edited and put the friend Packge.json !

  • 1

    Try to remove it: npm uninstall -g webpack-cli and install again: npm install -g webpack-cli

  • Friend worked , however appeared another problem already edited the question and put it, you could take a look ?

  • You should open another question, because it is another project, because you would notice by the directory C: Working Desktop Users

  • Thanks for the help Noobsaibot, thank you very much, it’s all working !

Show 1 more comment

1 answer

1


Error may have been caused due to argument order -g in command, which according to the documentation is:

npm install -g webpack-cli

other than the Yarn that is:

yarn add webpack-cli -g

Reference

Browser other questions tagged

You are not signed in. Login or sign up in order to post.