简体   繁体   English

Node.js package.json 脚本代码使用本地库还是全局库?

[英]Node.js package.json script code uses local or global libraries?

While installing using node,使用节点安装时,

will the script code in package.json use the local node_modules or the global one? package.json 中的脚本代码将使用本地 node_modules 还是全局 node_modules?

for instance here below, will it use the global browserify( npm install -g ) module or the locally installed one?例如在下面,它会使用全局 browserify( npm install -g ) 模块还是本地安装的模块? available in ./node_modules/bin./node_modules/bin可用

  "scripts": {
    "start": "watchify -o js/bundle.js -v -d .",
    "build": "browserify . | uglifyjs -cm > js/bundle.min.js"
  }

Package.json uses the local modules found in the same root directory (node_modules dir by default) the node script resides (or that configure in package.json) Package.json 使用在节点脚本所在的同一根目录(默认为 node_modules 目录)中找到的本地模块(或在 package.json 中配置的)

If module is installed globally it uses the global one.如果模块是全局安装的,它将使用全局模块。

Please read here: http://browsenpm.org/help请在此处阅读: http : //browsenpm.org/help

The -g flag will indicate that http-server should be installed globally, and be available for all node scripts to require. -g 标志将指示 http-server 应该全局安装,并且可供所有节点脚本使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM