How to execute commands if npm does not install dependencies globally

for example, I don"t have webpack installed globally
how to use the webpack command in shell

Mar.31,2021

upgrade your NPM to the latest (5.2 +), and then use the npx webpack parameter to execute.


.. / node_modules/.bin/webpack param
or
configure
script

using srcipt in the npm package.json file
webpack 

this is simple. After you have partially installed webpack in the project, you can write it in package.json

.
"scripts": {
    "dev": "node node_modules/webpack-dev-server/bin/webpack-dev-server.js  --progress --quiet --hot",
    "pro": "node node_modules/webpack/bin/webpack.js --progress --hide-modules"
  },

synthesize:

there are two schemes:

  1. / node_modules/.bin/webpack.
  2. npx webpack.

ps: among them. Representative parameter

Menu