npm not installing packages when i want to - npm

Most of the times when I try to install a package, I get this message:
npm ERR! Unexpected string in JSON at position 117 while parsing '{
npm ERR! "requires": true,
npm ERR! "lockfileVersion'
What is happening?

Your package.json must be of valid json syntax. If you're sure nothing is wrong with it , then it could be your package-lock.json file that is corrupted.delete it and run npm install again.

Related

How can I solve an error while using npm install?

I just wanna install dependencies for my project after cleaning "node_module" folder and deleting package-lock.json file:
npm install
And always get an error:
npm ERR! code EINVALIDTAGNAME
npm ERR! Invalid tag name "^" of package "eslint-plugin-react#^": Tags may not have
any characters that encodeURIComponent encodes.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Local\npm-cache\_logs\2023-01-31T16_45_46_763Z-
debug-0.log
and the same error when using yarn.

Whenever I run npm install in my terminal, I get "cb() never called"

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\JOVANNE DELA ROSA\AppData\Roaming\npm-cache\_logs\2021-07-16T20_58_48_839Z-debug.log
When we install a node packages from package.json file and package-lock.json file is corrupted due to some reasons like node.js version is updated to the latest, we will see an error like this in our terminal.
To fix this error, first delete the package-lock.json file and run the following command.
npm cache clean --force
Now, try to install your packages using the npm install command.

Craco - Could not resolve dependency error

I am trying to setup TailwindCSS in my Create-React-App project and I am trying to install craco so that I need not eject my CRA
When I run the following command npm install #craco/craco, I get unable to resolve dependency tree error. Below is the detail of the error. What should I do? Thanks
npm install #craco/craco
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: exchange#0.1.0
npm ERR! Found: react-scripts#3.4.3
npm ERR! node_modules/react-scripts
npm ERR! react-scripts#"3.4.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react-scripts#"^4.0.0" from #craco/craco#6.1.1
npm ERR! node_modules/#craco/craco
npm ERR! #craco/craco#"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
This works for me
npm install #craco/craco --save --legacy-peer-deps
With the below line you can also set --legacy-peer-deps permanently as a config option. Try to avoid this as you need to see which npm library/libraries in your project is/are having dependency issues.
npm config set legacy-peer-deps true
I've updated my package react-scripts to the latest version 4.x.
by running this command :
npm i react-scripts#latest
then lo and behold, I was able to install craco successfully.
Run this; it worked for me:
npm config set legacy-peer-deps true
Use yarn add, it would solve this for you, you don't need to do anything for the react-scripts version.
I think the error has to do with the dependency tree.
You have react-scripts#3.4.3 but #craco/craco requires react-scripts#4.0.0.
Simply run npm i react-scripts#4.0.0 and create craco.config.js file
i update my react app and then installed craco 5.05v
In my case using node v16.15.1 raising this error.
I resolved it by using node v16.13.1 with fixing the version in package.json
"engines": {
"node": "16.13.1"
},
You can also resolve by using yarn not npm.
Related issue:
Didn't want to upgrade react-scripts
So tried downgrading craco
It worked fine:
Commands that worked fine are below:
npm uninstall -g craco
npm uninstall -g #craco/craco
npm i -g craco#0.0.3
npm i -g #craco/craco#6.4.3
package.json contents:
"react-scripts": "^4.0.3",
"#craco/craco": "^6.4.3",
"craco": "^0.0.3",
If you are changing package.json then do:
npm i
npm install -f
Could help here.

npm install --save solc on Atom

When I type npm install --save solc in the comment prompt on the mac, it's like
And after these a package is downloaded. I am a windows user and I tried to do this. I have an error like
C:\Users\senem\Desktop\inbox>npm install --save solc
npm ERR! code EJSONPARSE
npm ERR! file C:\Users\senem\Desktop\inbox\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\senem\AppData\Roaming\npm-cache_logs\2021-03-04T23_05_05_768Z-debug.log
I can't download it because I don't know which package it is. Is there anyone who can help? How can I download this or how can I solve this error?

How Can I Uninstall browser-sync

I tried uninstalling browser-sync and it simply won't work.
I've tried multiple times and already looked at these questions:
Can't uninstall global npm packages after installing nvm
How to uninstall npm modules in node js?
I tried adding -g and it just says it's "up to date"...
>npm uninstall browser-sync
npm ERR! code EJSONPARSE
npm ERR! file C:\Users\justi\OneDrive\Documents\GitHub\triangle-calc\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token } in JSON at position 316 while parsing near '...les.css --watch",
npm ERR! JSON.parse },
npm ERR! JSON.parse "keywords": [],...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\justi\AppData\Roaming\npm-cache\_logs\2020-12-28T01_44_57_830Z-debug.log
>npm uninstall browser-sync -g
up to date in 0.063s
I haven't had this problem uninstalling anything else before. I'm hoping posting here someone will quickly find my stupid mistake. Thanks in advance.
There was an error in my package.json (admittedly as the output says). It was an extra comma (apparently that works in JS but not JSON). Leaving this up in case it helps someone else trying to uninstall a package.