I have downloaded Windows Binary (.exe) of nodejs from the main page.
How can I install and use npm
(Node package manager)?
The npm command is simple: npm install coffee-script -g . This will typically install the program and put a symlink to it in /usr/local/bin/ . This will then allow you to run the program from the console just like any other CLI tool.
Using a Node version manager to install Node. js and npm. Node version managers allow you to install and switch between multiple versions of Node. js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.
Some malware camouflages itself as node.exe which can be a security threat to your system. You can check if the file is located in the C:\Windows or C:\Windows\System32 folder, then it is a Trojan. The location for the legit file should be C:\Program Files or C:\Program Files (x86).
On most systems, this is /usr/local . On Windows, it's %AppData%\npm . On Unix systems, it's one level up, since node is typically installed at {prefix}/bin/node rather than {prefix}/node.exe .
The current windows installer from nodejs.org as of v0.6.11 (2012-02-20) will install NPM along with NodeJS.
NOTES:
%USERPROFILE%\AppData\Roaming\npm
%USERPROFILE%\AppData\Roaming\npm-cache
npm install
as that user. Some modules/utilities should be installed globally....\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):
[NODE_INSTALL_PATH]\etc\
directory npm config --global ...
actionsC:\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 herenpm config --global set prefix "C:\ProgramData\npm"
npm config --global set cache "C:\ProgramData\npm-cache"
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:
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 herenpm config set prefix "C:\Users\YOURNAME\AppData\Local\npm"
npm config set cache "C:\Users\YOURNAME\AppData\Local\npm-cache"
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.
More advanced JS options...
For testing, I reach for the following tools...
Web tooling.
If you build it...
scripts
directory that's referenced in package.json
scripts via npm. You can use gulp tools inside plain scripts.When Node.js is not installed using the msi installer, npm needs to be setup manually.
First, let's say we have the node.exe file located in the folder c:\nodejs
. Now to setup npm-
c:\nodejs\node_modules
and c:\nodejs\node_modules\npm
c:\nodejs\node_modules\npm
folderc:\nodejs\node_modules\npm\bin
to c:\nodejs
folderIn order to test npm, open cmd.exe
change working directory to c:\nodejs
and type npm --version
. You will see the version of npm if it is setup correctly.
Once setup is done, it can be used to install/uninstall packages locally or globally. For more information on using npm visit https://docs.npmjs.com/.
As the final step you can add node's folder path c:\nodejs
to the path
environment variable so that you don't have to specify full path when running node.exe
and npm
at command prompt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With