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

182 Views Asked by At

While installing using node,

will the script code in package.json use the local node_modules or the global one?

for instance here below, will it use the global browserify(npm install -g) module or the locally installed one? available in ./node_modules/bin

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

There are 1 best solutions below

0
On

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)

If module is installed globally it uses the global one.

Please read here: 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.