npm 相关任务在安装过程中抛出错误
npm related tasks are throwing errors during installations
我最近一直遇到这个问题,除了 npm start
。
与 npm 相关的任何东西都不适合我
npm install
出现此错误:
$ npm install @material-ui/core
npm ERR! Object for dependency "@babel/generator" is empty.
npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install".
npm ERR! If using a shrinkwrap, regenerate with "npm shrinkwrap".
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Parth\AppData\Roaming\npm-cache\_logs20-08-20T13_52_13_701Z-debug.log
npx create-react-app ./
出现此错误:
npx create-react-app ./
npx: installed 98 in 10.023s
Creating a new React app in G:\hel.
Installing packages. This might take a couple of minutes. Installing
react, react-dom, and react-scripts with cra-template...
yarn add v1.22.4 [1/4] Resolving packages... [2/4] Fetching
packages... error An unexpected error occurred: "UNKNOWN: unknown
error, unlink
'C:\Users\Parth\AppData\Local\Yarn\Cache\v6\npm-core-js-pure-3.6.4-4bf1ba866e25814f149d4e9aaa08c36173506e3a-integrity\node_modules\core-js-pure\features\object\is-frozen.js'".
info If you think this is a bug, please open a bug report with the
information provided in "G:\hel\yarn-error.log". info Visit
https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Aborting installation. yarnpkg add --exact react react-dom
react-scripts cra-template --cwd G:\hel has failed.
Deleting generated file... package.json Deleting generated file...
yarn.lock Done.
编辑: 所以我尝试使用 Yarn 进行安装,但出现此错误:
$ yarn add @material-ui/core
yarn add v1.22.4
warning package-lock.json found. Your project contains lock files generated by
tools other than Yarn. It is advised not to mix package managers in order to
avoid resolution inconsistencies caused by unsynchronized lock files. To clear
this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "UNKNOWN: unknown error, unlink
'C:\Users\Parth\AppData\Local\Yarn\Cache\v6\npm-core-js-pure-3.6.4-4bf1ba866e25814f149d4e9aaa08c36173506e3a-integrity\node_modules\core-js-pure\features\object\is-frozen.js'".
info If you think this is a bug, please open a bug report with the information
provided in "F:\Parth\covid-19-tracker\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
我该如何解决这个问题?
编辑: 我的 npm
版本是 6.14.8
首先你需要确保你的node和npm版本是最新的。如果不是,请将您的节点和 npm 包升级到最新版本。
nvm install 12.18.3 // update node version through node version manager
npm install npm // update your npm version to latest
删除您的 node_modules
文件夹、package-lock.json
和 yarn
文件(如果有)。
使用以下命令强制清理整个 NPM 缓存。
npm cache clean --force
Re-Install 所有依赖项。
npm install
如果上述步骤未能解决您的问题,请尝试通过从全局文件夹中删除 Yarn
文件夹然后 运行.
来全局卸载 yarn
npm uninstall -g yarn
我最近一直遇到这个问题,除了 npm start
。
npm install
出现此错误:
$ npm install @material-ui/core npm ERR! Object for dependency "@babel/generator" is empty. npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install". npm ERR! If using a shrinkwrap, regenerate with "npm shrinkwrap". npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Parth\AppData\Roaming\npm-cache\_logs20-08-20T13_52_13_701Z-debug.log
npx create-react-app ./
出现此错误:
npx create-react-app ./ npx: installed 98 in 10.023s Creating a new React app in G:\hel. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template... yarn add v1.22.4 [1/4] Resolving packages... [2/4] Fetching packages... error An unexpected error occurred: "UNKNOWN: unknown error, unlink 'C:\Users\Parth\AppData\Local\Yarn\Cache\v6\npm-core-js-pure-3.6.4-4bf1ba866e25814f149d4e9aaa08c36173506e3a-integrity\node_modules\core-js-pure\features\object\is-frozen.js'". info If you think this is a bug, please open a bug report with the information provided in "G:\hel\yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. Aborting installation. yarnpkg add --exact react react-dom react-scripts cra-template --cwd G:\hel has failed. Deleting generated file... package.json Deleting generated file... yarn.lock Done.
编辑: 所以我尝试使用 Yarn 进行安装,但出现此错误:
$ yarn add @material-ui/core yarn add v1.22.4 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] Resolving packages... [2/4] Fetching packages... error An unexpected error occurred: "UNKNOWN: unknown error, unlink 'C:\Users\Parth\AppData\Local\Yarn\Cache\v6\npm-core-js-pure-3.6.4-4bf1ba866e25814f149d4e9aaa08c36173506e3a-integrity\node_modules\core-js-pure\features\object\is-frozen.js'". info If you think this is a bug, please open a bug report with the information provided in "F:\Parth\covid-19-tracker\yarn-error.log". info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
我该如何解决这个问题?
编辑: 我的 npm
版本是 6.14.8
首先你需要确保你的node和npm版本是最新的。如果不是,请将您的节点和 npm 包升级到最新版本。
nvm install 12.18.3 // update node version through node version manager
npm install npm // update your npm version to latest
删除您的 node_modules
文件夹、package-lock.json
和 yarn
文件(如果有)。
使用以下命令强制清理整个 NPM 缓存。
npm cache clean --force
Re-Install 所有依赖项。
npm install
如果上述步骤未能解决您的问题,请尝试通过从全局文件夹中删除 Yarn
文件夹然后 运行.
yarn
npm uninstall -g yarn