Encounter error when installing react-router-dom - javascript

I get this error whenever I NPM install react-router-dom in vs code:
npm ERR! Unexpected end of JSON input while parsing near
'...stack-launcher":"^1.0'
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\HP\AppData\Roaming\npm-cache_logs\2019-03-18T09_03_43_417Z-debug.log

Seems like you missed a comma after '...stack-launcher":"^1.0' in the package.json file.
If not delete the node_modules folder, delete package-lock.json file, run npm cache clean --force and try to re-install.

Related

npm doesn't work for me because of wrong config

When I want to use the npm package manager for js we package or project like this command:
npm start
It shows me :
npm ERR! code E418
npm ERR! 418 Unknown - GET https://repo.huaweicloud.com/repository/npm/yarn
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Amir\AppData\Local\npm-cache\_logs\2021-12-08T13_04_36_000Z-debug.log
I think my npm mirror is wrong, how can I fix it?
You can use
npm config --global edit
and
npm config edit, it will open the npm config with your default editor.
and then remove the registry line for each file to reset it to defaults.

npm install error: Integrity Check failed

I have a github repo from where I pull the code and done npm install and that results in the error like,
npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting #my-package#^1.2.0:
npm ERR! Verification failed while extracting #my-package#^1.2.0:
npm ERR! Integrity check failed:
npm ERR! Wanted: sha512-lQ...HA==
npm ERR! Found: sha512-nH...ow==
Even though I referred multiple similar solutions like this, they are mentioning that we need to delete package-lock.json file but my lead has asked me not to delete lock file and it needs to be same for all the machines.
How can I get rid of this error without deleting package-lock.json file?
Deleting node_modules and doing npm i doesn't do any trick
and the above mentioned error still persists..

npm ERR! code E401 npm ERR! Incorrect or missing password

My Node version is 10.15.0 and NPM version is 6.8.4
On running npm install after upgrading
npm to 14.16.0 and npm to 7.6.2
Getting this error -
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xyz/.npm/_logs/2021-04-15T18_55_07_993Z-debug.log
Try Deleting the package-lock.json file before running the command "npm install" after upgrading the node versions, if you have not done that.
If that will not work try removing the .npmrc file in $HOME directory as mentioned in this post.
NPM ERR Code E401: Unable to authenticate, need: Bearer authorization
Note - Deleting package-lock.json can have its own issues as mentioned in this posts, so go with this solution unless you find any better solution.
Deleting `package-lock.json` to Resolve Conflicts quickly
In the directory C/Users/your-windows-username/
delete the following files:
.cache
.package
.package-lock
.npmrc
After that, go to your project and run the following command in your terminal
npm i
I had the same error with the company registry configured in .npmrc
registry=https:<company-registry-url>
Node version : 19.1.0
NPM version : 8.19.3
Solution:
Execute npm login
$ npm login
npm notice Log in on https:<registry-url>
Username: xxxx
Password:
Email: (this IS public) (xxxx)
Logged in as xxx on https:<registry-url>.
After this .npmrc got updated with
//<registry-url>/:_authToken=xxxxx
Your password in .npmrc must be base64 encoded. Easy to screw up just copy-pasting the password, need to base64 encode that.
I have been getting the same error recently on various projects after running npm run dev:
npm ERR! code E401
npm ERR! Incorrect or missing password.
What fixed it for me was to delete my package-lock.json file (and any yarn.lock files, which might create conflicts with npm) and the node_modules directory. Then I updated my npm packages with npm update. (CAUTION: Before updating any npm packages, you should probably create a new Git branch and run npm update in that new branch. If you run into bigger problems after the updates, then you can revert back to your previous branch.)
After my packages were updated, then running my npm startup script (e.g. npm run dev) worked again without errors.
NOTE: You can run npm outdated to see which of your npm packages could use an update.
Had the same issue with Node 16.x.x.
I have done everything from this topic and those topics which were mentioned here and nothing helped me!
The only thing that helped me to login was that I have deleted Node 16.x.x and installed Node 14.8.1 from here - https://nodejs.org/en/download/releases/
It can be happening because of a bug on npm. This was happening to me with npm v7. Switched to v6 and it worked.
More context: https://github.com/npm/cli/pull/2153
Reinstall the lastest node.js. That fixed my issue.

npm start throwing error 'This is related to npm not being able to find a file.'

I just created a react app, it was working fine but once I restart the editor it is throwing error like this :
Poojas-MacBook-Air:newreact pooja$ npm start
npm ERR! path /Users/pooja/Desktop/projects/newreact/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open
'/Users/pooja/Desktop/projects/newreact/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/pooja/.npm/_logs/2020-11-28T10_27_42_118Z-debug.log
Please help if anyone knows about it.
Make sure you have the latest npm (npm install -g npm).
Add an exception to your antivirus to ignore the node_modules folder in your project.
rm -rf node_modules package-lock.json
npm install
Sometimes the PATH is not correct, just open the cmd and cd to the address where the package.json is and then run npm start
For me, it was because of the running Metro server. If anyone is experiencing this issue in react-native, make sure you have stopped the running Metro server instance before entering npm i <package-name>.
With yarn, I think, there's no such issue.
To resolve package.json file, go to your project folder and find package.json location folder.
Open terminal and make sure your are in correct path where package.json file located.
eg: c://projectfolder/folder1/clientapp> npm start

I cannot install Webpack using npm

Every time I use npm install --save-dev webpack, the command line throws an error saying this:
npm ERR! Unexpected end of JSON input while parsing near '...it","version":"1.4.0"'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\usman\AppData\Roaming\npm-cache\_logs\2020-05-20T02_38_55_455Z-debug.log
I have tried rebooting my PC, install the webpack cli, re-installing Node.js but nothing seems to work. Please help.

Categories

Resources