this and that question is very important how to safely install webpack and uninstall webpack. The main purpose is to prevent webpack from breaking down and come back from the west. Ask the old driver to lead the way. When you go back at night, you may have to do the system
.just getting started
look at the documentation to install webpack4.x, globally
npm install --global webpack
webpack-cli is also installed by the way
npm install --save-dev webpack-cli
check version
webpack -v
the output is 4.10.2
I felt very nice at that time
< hr >the problem is that I also consider the problem of practicing hands directly
rm -rf node_modules package-lock.json
now there is a problem. I continue to install webpack
lifedeMBP:Documents life$ webpack
-bash: /Users/life/.nvm/versions/node/v10.3.0/bin/webpack: No such file or directory
lifedeMBP:Documents life$ npm install --global webpack
/Users/life/.nvm/versions/node/v10.3.0/bin/webpack -> /Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/bin/webpack.js
> fsevents@1.2.4 install /Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/node_modules/fsevents
> node install
[fsevents] Success: "/Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
+ webpack@4.11.0
added 387 packages from 296 contributors in 71.214s
lifedeMBP:Documents life$ webpack
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
- webpack-command (https://github.com/webpack-contrib/webpack-command)
A lightweight, opinionated webpack CLI.
We will use "npm" to install the CLI via "npm install -D".
Which one do you like to install (webpack-cli/webpack-command):
webpack-cli
Installing "webpack-cli" (running "npm install -D webpack-cli")...
npm WARN saveError ENOENT: no such file or directory, open "/Users/life/Documents/package.json"
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open "/Users/life/Documents/package.json"
npm WARN webpack-cli@3.0.2 requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.
npm WARN Documents No description
npm WARN Documents No repository field.
npm WARN Documents No README data
npm WARN Documents No license field.
+ webpack-cli@3.0.2
added 105 packages from 44 contributors and audited 143 packages in 25.231s
found 0 vulnerabilities
{ Error: Cannot find module "webpack-cli"
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at runCommand.then (/Users/life/.nvm/versions/node/v10.3.0/lib/node_modules/webpack/bin/webpack.js:149:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: "MODULE_NOT_FOUND" }
lifedeMBP:Documents life$
just kidding (I wonder if I"m going to build a new system for mac)