简体   繁体   English

NPM安装+使用本地模块? 在窗户上

[英]NPM install + use local modules? on windows

I created a package.json and added the needed dependencies (grunt, bower, jasmine etc) 我创建了一个package.json并添加了所需的依赖项(咕unt声,凉亭,茉莉花等)

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? 但是我的理解是“ -g”使安装全局化? (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. 您可以使用npm run-scripts创建一个命令,该命令将运行已安装的bower和grunt的本地副本。

In package.json , add a key like this: package.json ,添加如下键:

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

Then run the command npm run init . 然后运行命令npm run init

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

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