search

Home  >  Q&A  >  body text

node.js - npm本地安装模块后如何去运行

在使用npm install --save-dev webpack之后,将webpack安装到当前项目,但安装完成之后,运行webpack报出command not found: webpack的错误,网上说需要在package.json文件所在的文件夹下进入node_modules/.bin文件夹下,我在这个文件夹下找到了一个webpack文件,但是依旧无法运行webpack。本地安装npm模块后如何运行呢?

黄舟黄舟2785 days ago665

reply all(3)I'll reply

  • 黄舟

    黄舟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

    reply
    0
  • 高洛峰

    高洛峰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

    reply
    0
  • 阿神

    阿神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>
    

    reply
    0
  • Cancelreply