npm ERR! code ENOLOCAL Could not install from "" as it does not contain a package.json file.解决

一、问题描述

使用npm安装时出现以下问题,

$ npm install -g

npm ERR! code ENOLOCAL
npm 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安装,国内网速较慢)

中间出现了以下错误:

npm ERR! code ENOLOCAL Could not install from

node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)

此时需要单独安装以下node-gyp

 npm install -g node-gyp

之后,再使用:

cnpm install

ok


你可能感兴趣的:(Web,npm,ERR,code,ENOLOCAL.,s,not,contain,a,package.json,file,解决)