###npm sanity
Does running npm install
on a new project take a long time on your system?
Few things will wrangle high install/build times for node modules better than following this rule:
- Each time you
npm install
a project you're working on, take note of the npm modules that are installed into/node_modules
. You cantail
to a log file when runningnpm install
, or you can open the/node_modules
sub-directory within your project to see a list of everything that was installed. - For each of the modules installed there, install them globally instead, so that they don't have to be installed per-project every time. You can install a package from npm globally by using the global flag
-g
.
Example: npm install -g package-name
Here's an example that will copy the name of every node module in the project to your clipboard (OSX*). In your project root, enter:
find node_modules -type d | pbcopy
Tedious? Definitely. But you'll only have to do it once.
Congrats! Now your build times are 30 seconds
instead of MAX_INT minutes
.
*If using Linux, you'll need to use xclip
, or a similar library instead of pbcopy
.
This housekeeping method applies to most package managers.
does this apply to npm 3 where all node module deps are "hoisted" to the root of node_modules