【问题标题】:npm install throwing errorsnpm install 抛出错误
【发布时间】:2021-12-18 08:45:30
【问题描述】:

当调用npm installnpm install --save 时,代码会抛出相同的错误。

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/andyc/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/andyc/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/andyc/.npm/_logs/2021-11-04T02_19_18_554Z-debug.log

知道为什么会这样吗?

【问题讨论】:

  • 没有包。 json 文件在当前目录中。

标签: node.js linux npm


【解决方案1】:

您似乎没有 package.json。因此,对于每个新项目,您都需要遵循这些步骤

步数:1

npm init --yes

步骤:2

npm i --save 'packagename'

步骤:3 - 通过删除 node_modules 删除并重新安装包时,运行以下命令:

npm i/install

【讨论】:

    猜你喜欢
    • 2015-10-11
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 2022-01-17
    相关资源
    最近更新 更多