我在 MacOS 最新版本上使用 Visual Studio Code。
当我尝试运行
npm start
时,我遇到了很多错误,我已在此处发布了一个单独的问题:
我想再次安装所有可能的模块来解决当我尝试运行时的问题:
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 [email protected]: fsevents 1 will break on node v14+ and
could be using insecure binaries. Upgrade to fsevents 2.
我尝试使用这篇文章解决该问题:
但是当运行“npmauditfix”时我得到了一组新的错误:
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 cache clean --force
删除node_modules通过
$ rm -rf node_modules package-lock.json folder
或通过进入目录并右键单击>删除/移至垃圾箱来手动删除它。另外,也删除
package-lock.json
文件。
npm install
重新开始,
$ npm start
这对我有用。希望它也适合你。
PS:如果仍然存在,请检查它以红色显示的错误并采取相应措施。此错误特定于 Node.js 环境。