windows系統 nmp安裝時 出錯的解決辦法

使用npm安裝yeoman時出現了出現權限問題錯誤,問題解決後,第二個問題來了,當我npm install -g generator-angular 構建項目時,又出現類似權限問題,寶寶不開心了,

代碼如下:有相似代碼都可以參考

C:\Users\hld-ln>npm install -g yo
npm WARN deprecated [email protected]: this package has been reintegrated into npm a
nd is now out of date with respect to npm
npm ERR! tar.unpack untar error C:\Users\hld-ln\AppData\Roaming\npm-cache\string
_decoder\0.10.31\package.tgz
npm ERR! tar.unpack untar error C:\Users\hld-ln\AppData\Roaming\npm-cache\util-d
eprecate\1.0.2\package.tgz
npm ERR! tar.unpack untar error C:\Users\hld-ln\AppData\Roaming\npm-cache\string
_decoder\0.10.31\package.tgz
\
> [email protected] postinstall C:\Users\hld-ln\AppData\Roaming\npm\node_modules
\yo\node_modules\tabtab\node_modules\inquirer\node_modules\external-editor\node_
modules\spawn-sync
> node postinstall

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\node.js\\node.exe" "D:\\node.js\\node_modules\\npm\\bin\\npm-
cli.js" "install" "-g" "yo"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! path C:\Users\hld-ln\AppData\Roaming\npm\node_modules\yo\node_modules\y
eoman-environment\node_modules\mem-fs\node_modules\vinyl-file\node_modules\strip
-bom-stream\node_modules\first-chunk-stream\node_modules\readable-stream\node_mo
dules\string_decoder\index.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall open

npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\hld-ln\AppData\Ro
aming\npm\node_modules\yo\node_modules\yeoman-environment\node_modules\mem-fs\no
de_modules\vinyl-file\node_modules\strip-bom-stream\node_modules\first-chunk-str
eam\node_modules\readable-stream\node_modules\string_decoder\index.js'
npm ERR!     at Error (native)
npm ERR!  { [Error: EPERM: operation not permitted, open 'C:\Users\hld-ln\AppDat
a\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\node_modules\mem-f
s\node_modules\vinyl-file\node_modules\strip-bom-stream\node_modules\first-chunk
-stream\node_modules\readable-stream\node_modules\string_decoder\index.js']
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'C:\\Users\\hld-ln\\AppData\\Roaming\\npm\\node_modules\\yo\\no
de_modules\\yeoman-environment\\node_modules\\mem-fs\\node_modules\\vinyl-file\\
node_modules\\strip-bom-stream\\node_modules\\first-chunk-stream\\node_modules\\
readable-stream\\node_modules\\string_decoder\\index.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\hld-ln\npm-debug.log

解決辦法:

1:檢測npm的全局模塊的存放路徑是不是沒有配置好

配置方法:http://xiaoyaojones.blog.163.com/blog/static/28370125201351501113581/

這種方法解決了我第一個問題

2:第一個問題解決後,cdm 中輸入 yo doctor 檢測一下配置是不是有問題,是不是npm版本太老了(nodejs安裝後會自動幫我們安裝好npm,但他的版本多數不是最新的,需要cdm 中 輸入 npm install -g npm 更新版本,我就是這裏出毛病了)

以上辦法最好在管理員權限下運行

暫時出現這2個問題。。。希望別在出現其他問題。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章