Windows 7下node.js設定npm環境變數

來源:互聯網
上載者:User

前面日誌中的例子需運行“npm install formidable”指令安裝模組支援檔案上傳。

如果瀏覽器有Proxy 伺服器,或者辦公環境封殺了https,則需要設定npm環境變數。

我看到的錯誤提示資訊是這樣:

npm ERR! Error: failed to fetch from registry: formidable

首先查看環境變數預設值(沒準將來想設回去):

>npm config get proxy

null

>npm config get registry

https://registry.npmjs.org/

然後設定新值:

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

>npm config set proxy=http://10.2.3.4:8080 (此處代理應與瀏覽器代理設定相同)

如果繼續安裝看到下面的錯誤提示:

npm ERR! Please try running this command again as root/Administrator.

解決問題:“以管理員身份運行”cmd

通過“npm list”指令可看到我已在辦公環境成功安裝formidable和express:

C:\Windows\system32>npm list

C:\Windows\system32

├─┬ express@2.5.9

│ ├── connect@1.8.6

│ ├── mime@1.2.4

│ ├── mkdirp@0.3.0

│ └── qs@0.4.2

└── formidable@1.0.9

進入用例路徑,在啟動伺服器時看到下面的錯誤提示:

Error: Cannot find module 'formidable'

在同樣的路徑下再運行一次“npm install formidable”就行了(此處未究其原因)。

本文出自 “iData” 部落格,請務必保留此出處http://idata.blog.51cto.com/4581576/829802

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.