Build a node. js and npm working environment in windows, node. jsnpm
Recently, after studying the data visualization D3 framework, I decided to build a node. js and npm working environment under windows. I checked n Articles on the internet, regardless of whether to compile the source code for installation or use node. there is always a problem with the installation package in the msi format. In the end, the building is complete. As a newbie, I don't know if this is the case or not, but running 'npm install' does not go wrong.
The following describes some of my building processes:
- Download node. js. Download the latest node.exe file at http://nodejs.org/download /.
v0.10.33
. After the download is complete, create a new nodejs folder on the fdrive and put node.exe in this folder. At the same timeF:\nodejs
Add it to the PATH of the environment variable.
2. Download npm. Download the latest version of npmat http://nodejs.org/dist/npm. The version I downloaded isnpm-1.4.9.zip
. After the download is complete, decompress the package to the nodejs folder to form the following directory and add the environment variable.NODE_PATH
The value is:F:\nodejs\node_modules
- To test whether the installation is successful, enter
node -v
,npm -v
To check whether the version numbers of both are output. if the version numbers are output, the table is output successfully.
Due to XXX, you may often encounter downloading packages when using them. Therefore, it is best to set npm domestic images. The command is as follows:
npm config set registry http://registry.npmjs.vitecho.com
4. Test. Create a directory and create a new file under the directory.package.json
, The content is as follows:
{
"name": "d3-project-template-with-grunt",
"version": "0.0.1",
"description": "Ready to go d3 data visualization project template with grunt",
"keywords": [
"data visualization",
"d3"
],
"homepage": "<project home page>",
"author": {
"name": "<your name>",
"url": "<your url>"
},
"repository": {
"type": "git",
"url": "<source repo url>"
},
"dependencies": {
"d3": "3.x"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib": "~0.4.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-sass": "~0.4.1",
"grunt-contrib-jasmine": "~0.5.1",
"grunt-contrib-jshint": "~0.4.0",
"grunt-template-jasmine-istanbul": "~0.2.5"
},
"scripts": {
"test": "grunt jasmine"
}
}
5. Switch to this directory on the command line and runnpm install
If an error is reported and an error is automatically creatednode_modules
Directory andnpm-debug.log
File, and downloaded a bunch of files, it proves that the use is completely correct.