在使用npm install --save-dev webpack
之后,将webpack安装到当前项目,但安装完成之后,运行webpack报出command not found: webpack
的错误,网上说需要在package.json
文件所在的文件夹下进入node_modules/.bin
文件夹下,我在这个文件夹下找到了一个webpack文件,但是依旧无法运行webpack。本地安装npm模块后如何运行呢?
黄舟2017-04-17 15:39:00
You have to create a new webpack.config.js file in the project root directory
One hour package meeting
高洛峰2017-04-17 15:39:00
Still not installed correctly. First CD to the folder where the project is located on the command line, and then execute npm install --save-dev webpack
阿神2017-04-17 15:39:00
I just solved it myself
When installing a package with npm, if you use global installation, that is, npm install <packageName> -g
, you can run it as a command in the terminal after the installation is completed, but if it is a locally installed packagenpm install --save-dev <packageName>
, it cannot be run directly like this. So how do you run a locally installed package? First enter the project directory (that is, the directory where package.json is located), and then use the following command to run:
$ node_modules/.bin/<packageName>