【问题标题】:how to solve error code 1 when running npm运行npm时如何解决错误代码1
【发布时间】:2021-10-18 12:36:00
【问题描述】:

我在 Mac os 最新版本上使用 Visual Studio Code。

当我尝试运行 npm start 时遇到很多错误,我已在此处的单独问题中发布:

https://stackoverflow.com/questions/68795808/unable-to-solve-error-code-1-when-runningnpm-install

当我尝试运行时,我想再次安装所有可能的模块以解决问题:

npm i -g npm

我什至得到错误,其中一部分被复制到这里:

ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /usr/local/lib/node_modules/node/bin/node 
/usr/local/lib/node_modules/npm/bin/npm-cli.js install --force -- 
cache=/Users/afshinshahpari/.npm --prefer-offline=false --prefer-online=false -- 
offline=false --no-progress --no-save --no-audit --include=dev --include=peer -- 
include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN old lockfile 
npm ERR! npm WARN old lockfile The package-lock.json file was created with an old 
version of npm,
npm ERR! npm WARN old lockfile so supplemental metadata must be fetched from the 
registry.
npm ERR! npm WARN old lockfile 
npm ERR! npm WARN old lockfile This is a one-time fix-up, please be patient...
npm ERR! npm WARN old lockfile 
npm ERR! npm WARN deprecated fsevents@1.2.11: fsevents 1 will break on node v14+ and 
could be using insecure binaries. Upgrade to fsevents 2.

我尝试使用这篇文章解决此问题:

https://stackoverflow.com/questions/66434750/npm-err-git-dep-preparation-failed-when-trying-to-install-package-json

但是当运行“npm audit fix”时,我得到了一组新的错误:

npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/afshinshahpari/.npm/_logs/2021-08-16T12_46_15_639Z-debug.log

为了解决它,我使用了

npm i --package-lock-only

但没有成功。

【问题讨论】:

    标签: npm


    【解决方案1】:

    这是解决方案兄弟试试这个 第 1 步:$ npm cache clean --force

    步骤 2:通过 $ rm -rf node_modules package-lock.json 文件夹删除 node_modules 或通过进入目录并右键单击 > 删除 / 移动到垃圾箱手动删除它。另外,也删除 package-lock.json 文件。

    第 3 步:npm 安装

    要重新开始,$ npm start

    这对我有用。希望它也对你有用。

    PS:如果它仍然存在,请检查它以红色显示的错误并采取相应措施。此错误特定于 node.js 环境。

    【讨论】:

    • 感谢您的回答,但我已经尝试了这些步骤,并且在运行“npm install”时出现新错误:npm ERR!代码 ENOLOCK npm 错误! audit 此命令需要现有的锁定文件。
    猜你喜欢
    • 1970-01-01
    • 2021-07-27
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 2021-08-23
    相关资源
    最近更新 更多