原文:https://blog.csdn.net/u014182411/article/details/78964344

一、问题描述

使用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 "" as it does not contain a package.json file.解决

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

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

 npm install -g node-gyp

之后,再使用:

cnpm install

ok

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

相关文章:

  • 2021-06-20
  • 2022-12-23
  • 2022-03-01
  • 2021-07-02
  • 2021-07-16
  • 2022-01-21
  • 2021-08-10
  • 2021-09-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案