I’ve been having this problem recently that nothing related to npm is working for me except npm start
.
npm install
is giving this error:
JavaScriptx71$ npm install @material-ui/core
2npm ERR! Object for dependency "@babel/generator" is empty.
3npm ERR! Something went wrong. Regenerate the package-lock.json with "npm install".
4npm ERR! If using a shrinkwrap, regenerate with "npm shrinkwrap".
5npm ERR! A complete log of this run can be found in:
6npm ERR! C:UsersParthAppDataRoamingnpm-cache_logs2020-08-20T13_52_13_701Z-debug.log
7
npx create-react-app ./
is giving this error:
JavaScript122221npx create-react-app ./
2npx: installed 98 in 10.023s
3
4Creating a new React app in G:hel.
5
6Installing packages. This might take a couple of minutes. Installing
7react, react-dom, and react-scripts with cra-template
8
9yarn add v1.22.4 [1/4] Resolving packages [2/4] Fetching
10packages error An unexpected error occurred: "UNKNOWN: unknown
11error, unlink
12'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'".
13info If you think this is a bug, please open a bug report with the
14information provided in "G:\hel\yarn-error.log". info Visit
15https://yarnpkg.com/en/docs/cli/add for documentation about this command.
16
17Aborting installation. yarnpkg add --exact react react-dom
18react-scripts cra-template --cwd G:hel has failed.
19
20Deleting generated file package.json Deleting generated file
21yarn.lock Done.
22
EDIT: So I tried using Yarn for my installs but got this error:
JavaScript114141$ yarn add @material-ui/core
2yarn add v1.22.4
3warning package-lock.json found. Your project contains lock files generated by
4tools other than Yarn. It is advised not to mix package managers in order to
5avoid resolution inconsistencies caused by unsynchronized lock files. To clear
6this warning, remove package-lock.json.
7[1/4] Resolving packages
8[2/4] Fetching packages
9error An unexpected error occurred: "UNKNOWN: unknown error, unlink
10'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'".
11info If you think this is a bug, please open a bug report with the information
12provided in "F:\Parth\covid-19-tracker\yarn-error.log".
13info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
14
How do I fix this?
Edit: My version of npm
is 6.14.8
Advertisement
Answer
First of all you need to make sure that your node and npm versions are up to date. if not please upgrade your node and npm packages to latest versions.
JavaScript
1
4
1
nvm install 12.18.3 // update node version through node version manager
2
3
npm install npm // update your npm version to latest
4
Delete your node_modules
folder, package-lock.json
and yarn
file (if you have).
Force clean the entire NPM cache by using following comand.
JavaScript
1
2
1
npm cache clean --force
2
Re-Install all the dependencies.
JavaScript
1
2
1
npm install
2
If above step didn’t resolve your problem, try to uninstall yarn
globally by delete the Yarn
folder from global folder and then run.
JavaScript
1
2
1
npm uninstall -g yarn
2