简体   繁体   中英

NPM install + use local modules? on windows

I created a package.json and added the needed dependencies (grunt, bower, jasmine etc)

when I run

npm install

it correctly installs all the modules in

$pwd/node_modules/*

however when I try to USE those modules:

bower init; grunt init 

i get

sh.exe: (bower / grunt / w.e) Command not found 

I can solve this by using

npm install -g (package name)

but my understanding is the "-g" makes the install global? (is that correct?)

I want to be able to use the packages i installed locally...is this possible?

You can use npm run-scripts to create a command which will run the local copies of bower and grunt that you have installed.

In package.json , add a key like this:

"scripts": {
  "init": "bower init; grunt init"
}

Then run the command npm run init .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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