How to use executables from a package installed locally in node_modules?

前端 未结 22 1926
时光说笑
时光说笑 2020-11-22 12:40

How do I use a local version of a module in node.js. For example, in my app, I installed coffee-script:

npm install coffee-script
22条回答
  •  死守一世寂寞
    2020-11-22 13:05

    I prefer to not rely on shell aliases or another package.

    Adding a simple line to scripts section of your package.json, you can run local npm commands like

    npm run webpack

    package.json

    {
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "webpack": "webpack"
      },
      "devDependencies": {
        "webpack": "^4.1.1",
        "webpack-cli": "^2.0.11"
      }
    }
    

提交回复
热议问题