如何仅使用本地安装的npm软件包?

时间:2016-04-02 08:17:59

标签: npm gulp

例如,要启动本地安装的gulp,我必须从我的项目内部运行以下命令:

node_modules/gulp/bin/gulp.js

为了能够按名称启动npm packages ,我想将 node_modules 包含在项目的根目录中。这可能吗?

P.S
我知道如何在全局安装npm软件包,但我正在努力避免这样做。

1 个答案:

答案 0 :(得分:1)

I hope I understand you correctly: You are trying to execute programs like gulp from your local install.

You can set up a npm script like so in your package.json:

package.json

...
"scripts": {
  "build": "./node_modules/.bin/gulp"
}
...

Then, you can run gulp via npm run build from your command line. (Or optionally you can type ./node_modules/.bin/gulp)

相关问题