How to use npm with node.exe?

2019-01-04 18:14发布

I have downloaded Windows Binary (.exe) of nodejs from the main page.

How can I install and use npm (Node package manager)?

10条回答
贼婆χ
2楼-- · 2019-01-04 18:52

When Node.js is not installed using the msi installer, npm needs to be setup manually.

setting up npm

First, let's say we have the node.exe file located in the folder c:\nodejs. Now to setup npm-

  1. Download the latest npm release from GitHub (https://github.com/npm/npm/releases)
  2. Create folders c:\nodejs\node_modules and c:\nodejs\node_modules\npm
  3. Unzip the downloaded zip file in c:\nodejs\node_modules\npm folder
  4. Copy npm and npm.cmd files from c:\nodejs\node_modules\npm\bin to c:\nodejs folder

In 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.

查看更多
再贱就再见
3楼-- · 2019-01-04 18:57

I've just installed 64 bit Node.js v0.12.0 for Windows 8.1 from here. It's about 8MB and since it's an MSI you just double click to launch. It will automatically set up your environment paths etc.

Then to get the command line it's just [Win-Key]+[S] for search and then enter "node.js" as your search phrase.

Choose the Node.js Command Prompt entry NOT the Node.js entry.

Both will given you a command prompt but only the former will actually work. npm is built into that download so then just npm -whatever at prompt.

查看更多
萌系小妹纸
4楼-- · 2019-01-04 19:00

Search all .npmrc file in your system.

Please verify that the path you have given is correct. If not please remove the incorrect path.

查看更多
▲ chillily
5楼-- · 2019-01-04 19:01

I am running node.js on Windows with npm. The trick is simply use cygwin. I followed the howto under https://github.com/joyent/node/wiki/Building-node.js-on-Cygwin-(Windows) . But make sure that you use version 0.4.11 of nodejs or npm will fail!

查看更多
登录 后发表回答