npm related tasks are throwing errors during installations - javascript

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:
$ 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\_logs\2020-08-20T13_52_13_701Z-debug.log
npx create-react-app ./ is giving this error:
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.
EDIT: So I tried using Yarn for my installs but got this error:
$ 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.
How do I fix this?
Edit: My version of npm is 6.14.8

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.
nvm install 12.18.3 // update node version through node version manager
npm install npm // update your npm version to latest
Delete your node_modules folder, package-lock.json and yarn file (if you have).
Force clean the entire NPM cache by using following comand.
npm cache clean --force
Re-Install all the dependencies.
npm install
If above step didn't resolve your problem, try to uninstall yarn globally by delete the Yarn folder from global folder and then run.
npm uninstall -g yarn

Related

Error: You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1)

As the title says, I cannot run create-react-app.
You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1).
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
Doing this does not change the error. npm uninstall -g create-react-app
I entered this command to try it out and got a message that the tar was out of date.
npm install -g create-react-app
npm WARN deprecated tar#2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code EEXIST
npm ERR! path /opt/homebrew/bin/create-react-app
npm ERR! EEXIST: file already exists
npm ERR! File exists: /opt/homebrew/bin/create-react-app
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
https://www.npmjs.com/package/tar
I ran the command with this reference.
However, the tar was not updated.
I have already tried all the published solutions, but they don't work. Can someone please help me? Please.
I tried clearing the cache but could not solve the problem.
npx clear-npx-cache
Need to install the following packages:
clear-npx-cache
Ok to proceed? (y) y
I was able to successfully run the following command by specifying the version each time, but it is a hassle and I want to be able to run it normally.
npx create-react-app#latest my-app
The "fish" shell I am currently using is node v18.0.0, so I downgraded to v16.15.0 and it works fine.
fisher install jorgebucaran/nvm.fish
nvm install v16
I had forgotten to lower the node version in fish because it had been working fine with zsh.

I've been trying to create a react app but I keep getting this error: "npm ERR! cb() never called!"

this is the problem
HP#DESKTOP-1HP83V8 MINGW64 ~/Desktop/Web-Development (master)
$ npx create-react-app my-app
Creating a new React app in C:\Users\HP\Desktop\Web-Development\my-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HP\AppData\Roaming\npm-cache_logs\2020-11-20T11_50_51_060Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts >cra-template has failed.
I've encountered this multiple times.
First I would suggest that you run npm uninstall -g create-react-app since the global version isn't supported anymore.
Then try npx create-react-app my-app again.
If that does not work, try to run:
npm init
npm install create-react-app
npx create-react-app my-app
The steps above have solved the issue for me a couple of times
Disconnect and reconnect to your source of internet (WIFI).
After that, run npm cache verify
Next you will want to run: rerun npx create
Working Solution: thanks to idkwhatsgoingon's answer.
create-react-app does not work globally
npm uninstall -g create-react-app
npm install create-react-app
create-react-app app01
try this command first:
npm cache clean --force
and create your react app again.
I got the same error .Here these things i did to solve it
I ran npm cache clean --force
after again npx create-react-app project name
I tried all of these, it did not work. But I restarted the computer and it started working ! So after clearing the cache etc, might be be worth restarting the machine ( Windows 10 )
I got the same error when trying to install netlify-cli.
Here are two things I did to solve it:
I deleted some files to clear up disk space
Since my npm version is 6.0+, I ran "sudo npm cache verify"
Add the line
timeout=60000
to your .npmrc config file (create it at ~/.npmrc if it doesn't exist)
then run npx create-react-app project-name should be successful. At least it was in my case. (I had code ERR_SOCKET_TIMEOUT before)
Try installing yarn. I did this and immediately fixed my issues.
npm install --global yarn
first and foremost uninstall create-react-app by
npm uninstall -g create-react-app
then
npm cache clean -f
then
npx create-react-app app-name
this worked for me
I run npm cache verify
After this command, I run sudo apt install rerun
Then I run the command rerun npx create-react-app <app-name>
It worked like magic

Cannot Create React App Using create-react-app

I am trying to create a react app with
create-react-app
but it get the following error
Creating a new React app in /home/freduah/react-jumia-clone/react-jumia-clone.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
npm ERR! Unexpected end of JSON input while parsing near '...ct-assign":"^2.0.0","'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/freduah/.npm/_logs/2020-10-26T11_32_34_616Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting react-jumia-clone/ from /home/freduah/react-jumia-clone
Done.
Have you tried clearing your cache using npm cache clean --force?
Check your version of npm and other
or,
Try deleting cache in the terminal as :
npm cache clean --force

"npm ERR! unexpected end of JSON input near" while creating a new react app

[enter image description here][1]npm
I am trying for so many times to create a app in react but every time the CMD showing an ERR!
here is code :
Microsoft Windows [Version 10.0.18363.476]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Sumit>E:
The system cannot find the drive specified.
C:\Users\Sumit>D:
D:>React js
'React' is not recognized as an internal or external command,
operable program or batch file.
D:>react js
'react' is not recognized as an internal or external command,
operable program or batch file.
D:>React js
'React' is not recognized as an internal or external command,
operable program or batch file.
D:>create-react-app my_react
Creating a new React app in D:\my_react.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/react (over 30000ms)
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_33_43_496Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting my_react / from D:\
Done.
D:>create-react-app my-react-app
Creating a new React app in D:\my-react-app.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...Y3hEcJW8se9P4K6+GYGu9'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_34_57_334Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting my-react-app / from D:\
Done.
D:>create-react-app new-react
Creating a new React app in D:\new-react.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...gAAwSQP/RpJCkm/rgw8jt'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_38_28_735Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting new-react / from D:\
Done.
D:>npm create-react-app my-react-aplication
Usage: npm
where is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, fund, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm -h quick help on
npm -l display full usage info
npm help search for help on
npm help npm involved overview
Specify configs in the ini-formatted file:
C:\Users\Sumit.npmrc
or on the command line via: npm --key value
Config info can be viewed via: npm help config
npm#6.14.4 C:\Program Files\nodejs\node_modules\npm
D:>npx create-react-app my-react
Creating a new React app in D:\my-react.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...gAAwSQP/RpJCkm/rgw8jt'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Sumit\AppData\Roaming\npm-cache_logs\2020-06-01T14_54_02_126Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting my-react / from D:\
Done.
D:>
if you didn't install npm in general mode, it should better you do it with this comment in the root with the command
npm install -g
, or if you did it before you need to update it with the command
npm update [-g]
There are two things that you can do that might possibily help you resolve the issue you are facing.
1.If you are on a slow internet connection you might have to increase the timeout from 30s to 60s by adding this to your .npmrc file:
timeout=6000
You can find the .npmrc file at the path:
C:\Program Files\nodejs\node_modules\npm
2. This issue might be due to npm version mismatch, you can try to install the latest npm version by typing the following command in cmd:
npm install -g npm
Hope this helps!!

npm install couldnt install angularjs libraries

I have installed mean.io and ran sudo npm install. Actually following commands in sequence
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
sudo npm install
It is supposed to download and install angularjs libraries into public/system/lib. After doing the above steps public /system/lib is not created due to which when I start the application I get the error
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp/public/system/lib/bootstrap/dist/css/bootstrap.css'
[nodemon] app crashed - waiting for file changes before starting...
Is it something to do with certain npm/angularjs server being down. I have faced this problem earlier also but got fixed on 2nd try and I didn't bother to do more research. This became a big issue when I try to pull my repo into cloud and start the application. public/system/lib is added in .gitignore by default and is expected to be created during npm install.
I get following warnings with sudo npm install
npm WARN package.json mean-connect-mongo#0.4.3 No repository field.
npm WARN cannot run in wd mean#0.3.3 node node_modules/bower/bin/bower install (wd=/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp)
this is link to package.json
The problem maybe related to running npm install as sudo, which can cause problems. As mentioned in another stack overflow question, this can be worked around in a couple ways. But because it looks like this is being run from your home directory, you really shouldn't need to run npm install as root.
Try to issue the same commands, but the last without sudo:
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
npm install
Note that the reason you may need to run npm install -g <package> using sudo is because by default npm uses /usr/local for global installs, which can be a restricted directory. However, when you install a package locally (without the -g flag) you should not need to run as root.

Categories

Resources