How to reset the -g parameter for "npm install" in hook scripts?

I have the following project structure:

project structure

install.js:

var path = require('path'),
    exec = require('child_process').exec;

exec('npm install', {cwd: path.join(__dirname, './some_modules')});

      

package.json:

"scripts": {
  "install": "node install.js"
},
"dependencies": {
  "gulp": "3.8.10"
},

      

And have some dependencies in some_modules / package.json.

If installed locally, we get the expected result:

enter image description here

But when installed globally (with the -g option), we have the following broken structure: enter image description here

Question: How to get rid of the -g parameter value for install.js -> exec ('npm install')?

Try it here: https://github.com/MishaMykhalyuk/npm-i-with-g-and-hooks (npm install -g git + https://github.com/MishaMykhalyuk/npm-i-with-g-and -hooks.git ).

+3


source to share





All Articles