npm ERR! code ENOLOCAL Could not install from "" as it does not contain a package.json file.解決
阿新 • • 發佈:2019-01-06
一、問題描述
使用npm安裝時出現以下問題,
$ npm install -g
npm ERR! code ENOLOCALnpm ERR! Could not install from "" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ylt\AppData\Roaming\npm-cache\_logs\2018-01-03T10_44_58_269Z-debug.log
Could not install from "" as it does not contain a package.json file.
二、解決方案
更新npm:
npm install -g install
將專案下的node_modules刪除之後,使用npm install重新安裝
rm -r -f node_modules
cpm install(我使用了淘寶映象安裝,不然使用npm安裝,國內網速較慢)
中間出現了以下錯誤:
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
此時需要單獨安裝以下node-gyp
npm install -g node-gyp
之後,再使用:
cnpm install
ok