简体   繁体   中英

Homebrew Install Node Location

Kinda 2 questions related to each other here.

  1. When doing a brew install node, should I first navigate to the root of whatever folder I'm going to hold all my future web projects/apps then run it? Or does it not matter where I run the install initially for Node? Because I notice it creates a node_modules folder in /local/lib/node_modules

  2. I assume it doesn't matter, and when you start installing node packages using npm install [package] it'll create a separate node_modules folder under the context you're in so lets say /www/MyApplication run npm install and it'll create /www/MyApplication/node_modules ....and that the one under /local/lib/node_modules just serves as the one for npm itself because it needs its own root node_modules folder which is how npm runs?

  1. Correct, it makes no difference where you run brew install node , it will install into your Homebrew folder.
  2. When you use npm to install a Node module, it will install into the current directory, unless you use the -g global flag. Normally you will install modules that are project dependencies into your project folder, and global modules are for global utilities.

For example, to use Grunt you would install the grunt-cli package globally for the command-line utility.

npm install -g grunt-cli

And for each project that uses Grunt you will install a version of the grunt module for use with the project.

npm install grunt

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