webpack command not working

前端 未结 7 1814
谎友^
谎友^ 2020-12-01 04:09

I am new to Node Js and Webpack. I tried to start a project with module-loaders.

Firstly, I installed nodeJs and NPM and created a new directory called tutoria

相关标签:
7条回答
  • 2020-12-01 05:02

    webpack is not only in your node-modules/webpack/bin/ directory, it's also linked in node_modules/.bin.

    You have the npm bin command to get the folder where npm will install executables.

    You can use the scripts property of your package.json to use webpack from this directory which will be exported.

    "scripts": {
      "scriptName": "webpack --config etc..."
    }
    

    For example:

    "scripts": {
      "build": "webpack --config webpack.config.js"
    }
    

    You can then run it with:

    npm run build
    

    Or even with arguments:

    npm run build -- <args>
    

    This allow you to have you webpack.config.js in the root folder of your project without having webpack globally installed or having your webpack configuration in the node_modules folder.

    0 讨论(0)
提交回复
热议问题