windows下搭建node.js及npm的工作環境,node.jsnpm

來源:互聯網
上載者:User

windows下搭建node.js及npm的工作環境,node.jsnpm

最近在研究資料視覺效果D3架構,決定在windows下搭建一個nodejs及npm的工作環境,在網上查了n篇文章,別管是編譯源碼安裝也好,還是使用node.msi格式安裝包也好,總是有問題。最終,功夫不負有心人,還是搭建完成了。作為新手,其實我也不知道這樣搭建對不對,但是運行'npm install'反正不出錯了。

下面就把我的一些搭建過程說一下:

  1. 下載node.js。在http://nodejs.org/download/下載最新版的node.exe檔案,我下載時是v0.10.33。下載完成後,在F盤建立nodejs檔案夾,將node.exe放到該檔案夾下。同時將F:\nodejs添加到環境變數的PATH中。
    2.下載npm。在http://nodejs.org/dist/npm/下載最新版的npm。我下載時的版本是npm-1.4.9.zip。下載完成後,解壓到nodejs檔案夾中,形成了如下目錄,同時添加環境變數NODE_PATH,其值為:F:\nodejs\node_modules

  2. 測試是否安裝成功,在命令列中,分別輸入node -v、npm -v,看是否輸出兩者的版本號碼,如果輸出,則表時輸出成功
  3. 由於XXX原因,使用時會經常遇到下載包下載不下來的情況,所以最好設定npm國內鏡像,命令如下:

     npm config set registry http://registry.npmjs.vitecho.com

    4. 測試一下,建立一目錄,在該目錄下建立一檔案package.json,內容如下:

     {     "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. 在命令列切換到該目錄下,運行npm install,如果會報錯,且自動建立了node_modules目錄和npm-debug.log檔案,並下載了一堆檔案,則證明使用完全沒有問題。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.