Unable to install a package on Next JS - javascript

I've been trying to install styled-components on Next JS by entering npm install --save styled-components but it keeps giving me this error...
npm ERR! Unexpected end of JSON input while parsing near '...ry.npmjs.org/fork-ts-'
Please can anyone help me out?

Try to clean the npm cache running the following command:
npm cache clean --force

Related

Error in installing openVPN module in node js

I am trying to connect Sophos VPN using nodejs. For this I am referring below link
https://github.com/luigiplr/node-openvpn
So while executing npm install node-openvpn --save command I am getting error. Can anyone please help me with this issue? Below is the screenshot of error
enter image description here
Clean your cache and try again:
npm cache clean --force
npm install node-openvpn --save

how to fix npm audit error with loadVirtual and ENOLOCK?

➜ npm audit
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
I ran npm audit and got this error.
When I run below:
➜ npm config get package-lock
true
➜ npm config get shrinkwrap
true
Can anybody help with this? as to how to fix it? and npm audit fix --force is not working as well...
I just ran the command it says to.
npm i --package-lock-only
Then it showed me 0 vulnerabilities.
Anyway, ran again audit fix and again 0 vulnerabilities.
works for me like this:
npm cache clean --force
npm fund
npm audit fix --force
The problem is that you need a package.json and package-lock.json file in the directory.
Running the following commands will fix it for you.
npm init -y
npm i --package-lock-only
npm audit
This fixes the problem
That error tells you the root of the problem: This command requires an existing lockfile.. This implies that you don't already have a package-lock.json along side the package.json you're trying to audit. npm i --package-lock-only just generates/updates package-lock.json without reinstalling; npm i would reinstall and generate one (based on your config).
You need to create package-lock.json, run
npm install
then
npm audit fix
you won't have the problem
I updated to the latest version of npm with npm install -g npm#8.3.0, and now it shows no more problems...
Try running these:
npm i --package-lock-only
npm config get package-lock
npm config get shrinkwrap
npm i --package-lock-only
npm audit fix
From here.
Use Node 14, it fixed the issue with 0 vulnerabilities.
I read this and really helpful:
https://medium.com/illumination/how-to-fix-npm-audit-error-with-loadvirtual-and-enolock-deprecated-dependencies-1f07ba65eef9
npm i --package-lock-only
npm config get package-lock
npm config get shrinkwrap
npm i --package-lock-only
npm audit fix
(When running ‘npm config get package-lock’ and ‘npm config get shrinkwrap’, you will receive ‘true’ for both)
— → After running ‘npm audit fix’, you will see: “up to date, audited… found 0 vulnerabilities”
Had the same error, then realized I was in a parent folder. So this may happen if there's no lock file.
Try running this command:
npm cache clean --force

vue create with e2e showing strange error

I tried creating project using vue create but I get following error all the time
✨ Creating project in C:\Users\....
⚙️ Installing CLI plugins. This might take a while...
npm ERR! Unexpected end of JSON input while parsing near '..."^5.8.23","babel-tape'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\HariC\AppData\Roaming\npm-cache\_logs\2020-08-01T13_14_04_441Z-debug.log
ERROR command failed: npm install --loglevel error
I have chosen everything in except typescript support and es-lint while creating the app.
What could be the reason?
Try clearing the cache:
npm cache clean --force
Probably the error was due to corrupt cache. Referred to - https://stackoverflow.com/a/47896884/9640177
npm cache clean --force

Unable to install a npm package and dependency

I'm trying to adapt an external API named cric-live into my node application for displaying cricket scores in my application. When I try to install the dependency, it shows an error as below
PS F:\Node Express\NodeJS\cric api> npm i cric-live
npm ERR! Unexpected end of JSON input while parsing near '...":"request-promise","'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Thiluxan\AppData\Roaming\npm-cache\_logs\2020-07-01T04_51_42_400Z-debug.log
This is the source link for the dependency I'm trying to install
https://www.npmjs.com/package/cric-live?activeTab=readme
Your npm cache maybe busted so I would say run this code first and try installing the package again
npm cache clean --force

npm ERR! Unexpected end of JSON input while parsing near '...nt":"^7.1.0","babel-p'

I am new to react and I am trying to create a new create an app, but whatever I do, I get same error.
:npm ERR! Unexpected end of JSON input while parsing near '...nt":"^7.1.0","babel-p'
I think there is some problem with babel.
C:\Users\Augustus\Desktop>npx create-react-app myapp
Creating a new React app in C:\Users\Augustus\Desktop\myapp.
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 '...nt":"^7.1.0","babel-p'
npm ERR! A complete log of this run can be found in:
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... package.json
Deleting myapp/ from C:\Users\Augustus\Desktop
Done.
force a reinstall
usually you can fix these kinds of errors by forcing a reinstall
try
npm cache clean --force
or
yarn --force
depending on if you are using npm or yarn for package management
After forcing a reinstall, if you see that you are still getting the same error, check your internet connection. I had the same issue until I switched to a faster provider (in my third world country, internet can be slow at times) after which it immediately installed as it should have.

Categories