The current windows installer from nodejs.org as of v0.6.11 (2012-02-20) will install NPM along with NodeJS.
NOTES:
- At this point, the 64-bit version is your best bet
- The install path for 32-bit node is “Program Files (x86)” in 64-bit windows.
- You may also need to add quotes to the path statement in environment variables, this only seems to be in some cases that I’ve seen.
- In Windows, the global install path is actually in your user’s profile directory
%USERPROFILE%\AppData\Roaming\npm
%USERPROFILE%\AppData\Roaming\npm-cache
- WARNING: If you’re doing timed events or other automation as a different user, make sure you run
npm install
as that user. Some modules/utilities should be installed globally. - INSTALLER BUGS: You may have to create these directories or add the
...\npm
directory to your users path yourself.
To change the “global” location for all users to a more appropriate shared global location %ALLUSERSPROFILE%\(npm|npm-cache)
(do this as an administrator):
- create an
[NODE_INSTALL_PATH]\etc\
directory- this is needed before you try
npm config --global ...
actions
- this is needed before you try
- create the global (admin) location(s) for npm modules
C:\ProgramData\npm-cache
– npm modules will go hereC:\ProgramData\npm
– binary scripts for globally installed modules will go hereC:\ProgramData\npm\node_modules
– globally installed modules will go here- set the permissions appropriately
- administrators: modify
- authenticated users: read/execute
- Set global configuration settings (Administrator Command Prompt)
npm config --global set prefix "C:\ProgramData\npm"
npm config --global set cache "C:\ProgramData\npm-cache"
- Add
C:\ProgramData\npm
to your System’s Path environment variable
If you want to change your user’s “global” location to %LOCALAPPDATA%\(npm|npm-cache)
path instead:
- Create the necessary directories
C:\Users\YOURNAME\AppData\Local\npm-cache
– npm modules will go hereC:\Users\YOURNAME\AppData\Local\npm
– binary scripts for installed modules will go hereC:\Users\YOURNAME\AppData\Local\npm\node_modules
– globally installed modules will go here
- Configure npm
npm config set prefix "C:\Users\YOURNAME\AppData\Local\npm"
npm config set cache "C:\Users\YOURNAME\AppData\Local\npm-cache"
- Add the new npm path to your environment’s
PATH
.setx PATH "%PATH%;C:\Users\YOURNAME\AppData\Local\npm"
For beginners, some of the npm modules I’ve made the most use of are as follows.
axios – for more complex http posts/gets- isomorphic-fetch – for http(s) post/get requests
- node-mailer – smtp client
- mssql – interface and driver library for querying MS SQL Server (wraps tedious)
More advanced JS options…
- async/await – async functions, supported via babel
For testing, I reach for the following tools…
mocha – testing frameworkchai – assertion library, I like chai.expectsinon – spies and stubs and shimssinon-chai – extend chai with sinon’s assertion toolsbabel-istanbul – coverage reports- jest – parallel testing, assertions, mocking, coverage reports in one tool
- babel-plugin-rewire – slightly easier for some mocking conditions vs. jest
Web tooling.
- webpack – module bundler, package node-style modules for browser usage
- babel – convert modern JS (ES2015+) syntax for your deployment environment.
If you build it…