how do I resolve this node-sass installation error - node.js

npm ERR! Unexpected end of JSON input while parsing near '...--END PGP SIGNATURE--'
I keep getting this error while trying to install node-saas. I have even tried disabling anti-virus & windows defender.
I am using this command to install node sass:
npm install node-sass

Please check the below steps:
Please delete your package.lock.json file, along with that delete your node_modules folder.
Then clear all your npm cache by npm cache clean --force.
Install node-sass globally by using npm install -g node-sass
Once done with node-sass that run your npm install && npm start.
Hope this should work fine.

Related

npm i not working? npm ERR! Unexpected token '.'

My npm install seems to have stopped working out of nowhere, regardless of if i do npm i or npm install I keep getting an error saying npm ERR! Unexpected token '.' The other npm commands seem to be working perfectly but I can't install any modules because of this error. I'm using npm 8.7.0 and node v14.18.1
The simplest solution I could find and what worked for me was completely removing and unisntalling everything to do with nodejs and npm from my laptop. I then reinstalled it back with no issues and am able to use the command now.
As mentioned in one of the answers, try deleting the node_modules folder and package.lock.json. Use
sudo npm install
And if that doesn't work, what I would suggest is that you use yarn. If you don't know what yarn is, it's just a package manager like node.
You can install yarn by using the following command:
npm install -g yarn
After this make sure all the node modules and package.lock.json is deleted. Now run the command
yarn install
Hopefully, this will fix your issue.

Not able to install express via npm [duplicate]

When creating a new Angular 5 project:
node version: 8.9.2
npm version: 5.5.1
My Command is:
npm install -g #angular/cli
The Error is:
npm ERR! **Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'**
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aashitec\AppData\Roaming\npm-cache\_logs\2017-12-06T13_10_10_729Z-debug.log
The error log is here
This solved it for me:
Open Windows Powershell as admin
npm cache clean --force
npm install -g #angular/cli
https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/
Solution:
npm cache clean --force
then try again to create your app (here when creating a react app) or install what you were about to install.
create-react-app myproject
(creating react app)[same npm problem that can occur in different operation]
npm install -g #angular/cli#latest
(installing angular cli (or installing anything else))
It will work.
explanation:
That's a problem related to npm, it's about the cache that get corrupt. Even though in newer versions of npm they implemented self healing, which normally guarantee no corruption, but it seem it's not that efficient.
Forcing clean cache resolve the problem.
The error happen when parsing one of the cache files, which have a json format. The cache is found at ~/.npm/_cacache (in linux) and %AppData%/npm-cache (windows). For my current npm version and when i checked, there was three directories.
if you check the first or the second, the structure is as follow
And each cache file have a json format (and that what get parsed)
Here a good link from the doc: https://docs.npmjs.com/cli/cache
[Update] Also if it happen that this didn't solve it, you may check this answer here https://stackoverflow.com/a/50191315/7668448 it show how you can change the npm registry, that can be helpful. Check and see.
If
npm cache clean --force
doesn't work.
try
npm cache clean --force
npm update
Npm uses Cache for downloading new packages for you.
You need to clear your npm cache.
use following command to clean :
npm cache clean --force
then normally use your npm install command
e.g.
npm install -g #angular/cli
I solve that with
npm cache clean --force
then update npm
npm i npm#latest -g
then normally use your npm install command
npm install
delete npm and npm-cache folders in C:\Users\admin\AppData\Roaming\ (windows)
then execute cmd
npm cache clear --force
npm cache verify
update npm to latest version
npm i -g npm
then create your project
1)Angular
npm i -g #angular/cli#latest
ng new HelloWorld
2)React
npm i -g create-react-app
create-react-app react-app
None of the 30 answers here worked for me. I needed to:
delete node_modules and package-lock.json
npm cache clean --force
npm install -g #angular/cli
npm i --package-lock-only
npm ci
Phew!
this solved it npm cache clean --force
Simple solutions:
npm cache clean --force
npm install
This command alone solved my problem:
npm cache clean --force
Also you should make sure you are using the correct version of node.
Using nvm to manage the node version:
nvm list; # check your local versions;
nvm install 10.10.0; # install a new remote version;
nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;
I use Windows and removed all the files that were listed below and my problem was solved
C:\Users{{your-username}}\AppData\Roaming\npm-cache
npm cache clean --force worked for me
Error Resolved :
$ npm install -g gulp
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm ERR! Unexpected end of JSON input while parsing near '.../RGs88STtAtiMP3tCiNdU'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache_logs\2018-11-20T07_38_56_733Z-debug.log
Solution
npm cache clean --force
For Windows : go to C:\Users\username\AppData\Roaming\npm-cache
Delete all files and run
npm install && npm start
I solved that by first cleaning the cache using
npm cache clean --force
Then
npm install -g #angular/cli
My case - Windows 7 (had nothing better at the needed moment).
Helped me the following:
Deleting everything from C:\Users\username\AppData\Roaming\npm-cache
AND
Deleting package-lock.json
I resolved my problem with this one liner
npm cache clean --force
Note: since its a clean install, I had no concerns emptying npm cache.
ERROR: npm ERR! Unexpected end of JSON input while parsing near '...ore-js":"3.0.0-beta.1
This occurs when installing the expo CLI globally, This works for me!
npm cache clean --force
I got error (file already exists --force to overwrite) after running the following code:
npm cache clean --force
npm install -g #angular/cli
I solved it using :
npm i -g --force npm
Make sure to run the first commands to flush the cache of npm.
It's error from your npm....
So unistall node and install it again.
It works....
PS: After installing node again, install angular cli globally.
npm install -g #angular/cli#latest
I solve that with
First delete package-lock.json
npm cache clean --force
then update npm
npm i npm#latest -g
then use npm install command
npm install
If you looking for npm install and getting same kind of error
Delete package-lock.json and npm cache clean --force and try
In my case I changed the network to a much stronger one and npm install worked perfectly:
npm cache clean --force
If npm cache clean --force doesn't resolve the issue, try deleting the ~/.npm directory (*nix/macOS). This is the directory where node stores its cache, locks, logs, global packages (unless you're using nvm), and modules installed via npx.
First, backup your current ~/.npm directory:
mv ~/.npm ~/.npm-backup
Now try running your npm command again. This will create a new ~/.npm directory. If the issue is resolved, you can safely remove you backup. Before doing so, you may want to review the global packages installed in your ~/.npm-backup directory so you can reinstall them using npm i -g [package].
rm -rf ~/.npm-backup
If the issue is not resolved, you can restore your backup:
rm -rf ~/.npm
mv ~/.npm-backup ~/.npm
Careful with those rm commands, folks!
Instead of clearing the cache you can set a temporary folder:
npm install --cache /tmp/empty-cache
or
npm install --global --cache /tmp/empty-cache
As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use npm cache verify instead. On the other hand, if you're debugging an issue with the installer, you can use npm install --cache /tmp/empty-cache to use a temporary cache instead of nuking the actual one.
For me I had to clone my branch again and do npm install
You can use yarn package manager instead of npm.
It solved this problem for me
I've faced this issue and I tried all the answers on Stackoverflow but not worked for me, finally I found solution for this issue:
First of all you have to uninstall nodejs and remove all the files related him
Go to "Register Editor" and search for all "nodejs", "node.js" and delete them
Restart your computer
And reinstall nodejs then install angular.
It's worked for me
These commands worked for me
sudo npm cache clean --force
sudo npm cache verify
sudo npm i npm#latest -g
Try setting
npm config set strict-ssl false
and then try running,
npm install -g #angular/cli
This happens something due to cache or outdated version of Node Package Manager
i just updated my NPM it works fine
here is command to update Npm to latest version
npm i npm#latest -g
after updating NPM run your desired command

Why does the newest Angular CLI have a corrupted packages?

I installed the latest Node and Angular on Windows 10
npm install npm#latest -g
npm install -g #angular/cli#latest
But when I try to start a project ng new new-project I get the following error
npm WARN tarball tarball data for #angular/compiler#^6.1.0 (sha512-TY6axB1c7VvYXf+ebFDq3Ej+edgii3CDxew8HnyTFAWeDF2Gh8io1vTYwtdyDka6U53ASaheM1HpiUjzvYH0jQ==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\admin\Desktop\...\node_modules\.staging\#angular\common-6be83a81\locales\si.js'
...
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2018-10-08T01_01_48_404Z-debug.log
Package install failed, see above.
I tried to uninstall Node.js and Angular CLI completely and then reinstall again
npm install npm#latest -g
npm install -g #angular/cli#latest
But still the same error ..... So I googled this issue. It seems like some people had it too, but then it magically disappeared for some people.
How to fix this?
I was getting the same below error when attempting to a create new project using ng new command.
npm WARN tarball tarball data for #angular/compiler#~7.2.0
(sha512-5yb4NcLk8GuXkYf7Dcor4XkGueYp4dgihzDmMjYDUrV0NPhubKlr+SwGtLOtzgRBWJ1I2bO0S3zwa0q0OgIPOw==)
seems to be corrupted. Trying one more time.
I tried many things but what did not worked and what finally worked for me I have listed below. My working node version is 12.2.0 and npm version is 6.9.0 (i.e. latest version).
What did not worked:
Downgraded node js to other lower versions (tried many version)
Deleted package-lock.json file from project and executed npm install
Executed npm install --registry https://registry.cnpmjs.org instead of npm install
Deleted npm and npm-cache folders from AppData\Roaming and then again installed node js
Deleted node_modules folder, executed npm update and then executed npm install
Executed npm cache clean --force and then executed npm install
Reinstalled #angular/cli
Checked for any firewall / antivirus (in my case it was disabled)
Opened node command prompt as an administrator
Checked user permissions for the project folder
Finally what worked is:
Installed the component for which it was giving error. npm install -global #angular/compiler
I had the same problem with node 12.13.0 and npm 6.13.0
npm WARN tarball tarball data for #angular/compiler#^7.2.11 (sha512-5yb4NcLk8GuXkYf7Dcor4XkGueYp4dgihzDmMjYDUrV0NPhubKlr+SwGtLOtzgRBWJ1I2bO0S3zwa0q0OgIPOw==) seems to be corrupted. Trying one more time.
For me the problem was npm. After upgrading npm to the newest version with npm i -g npm#latest the problem vanished. So it seems to be a problem with npm itself and not the Angular/CLI.
upgrade your NPM version use this command i -g npm#latest it works like magic

NPM Install Error:Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'

When creating a new Angular 5 project:
node version: 8.9.2
npm version: 5.5.1
My Command is:
npm install -g #angular/cli
The Error is:
npm ERR! **Unexpected end of JSON input while parsing near '...nt-webpack-plugin":"0'**
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aashitec\AppData\Roaming\npm-cache\_logs\2017-12-06T13_10_10_729Z-debug.log
The error log is here
This solved it for me:
Open Windows Powershell as admin
npm cache clean --force
npm install -g #angular/cli
https://devblogs.microsoft.com/premier-developer/getting-started-with-node-js-angular-and-visual-studio-code/
Solution:
npm cache clean --force
then try again to create your app (here when creating a react app) or install what you were about to install.
create-react-app myproject
(creating react app)[same npm problem that can occur in different operation]
npm install -g #angular/cli#latest
(installing angular cli (or installing anything else))
It will work.
explanation:
That's a problem related to npm, it's about the cache that get corrupt. Even though in newer versions of npm they implemented self healing, which normally guarantee no corruption, but it seem it's not that efficient.
Forcing clean cache resolve the problem.
The error happen when parsing one of the cache files, which have a json format. The cache is found at ~/.npm/_cacache (in linux) and %AppData%/npm-cache (windows). For my current npm version and when i checked, there was three directories.
if you check the first or the second, the structure is as follow
And each cache file have a json format (and that what get parsed)
Here a good link from the doc: https://docs.npmjs.com/cli/cache
[Update] Also if it happen that this didn't solve it, you may check this answer here https://stackoverflow.com/a/50191315/7668448 it show how you can change the npm registry, that can be helpful. Check and see.
If
npm cache clean --force
doesn't work.
try
npm cache clean --force
npm update
Npm uses Cache for downloading new packages for you.
You need to clear your npm cache.
use following command to clean :
npm cache clean --force
then normally use your npm install command
e.g.
npm install -g #angular/cli
I solve that with
npm cache clean --force
then update npm
npm i npm#latest -g
then normally use your npm install command
npm install
delete npm and npm-cache folders in C:\Users\admin\AppData\Roaming\ (windows)
then execute cmd
npm cache clear --force
npm cache verify
update npm to latest version
npm i -g npm
then create your project
1)Angular
npm i -g #angular/cli#latest
ng new HelloWorld
2)React
npm i -g create-react-app
create-react-app react-app
None of the 30 answers here worked for me. I needed to:
delete node_modules and package-lock.json
npm cache clean --force
npm install -g #angular/cli
npm i --package-lock-only
npm ci
Phew!
this solved it npm cache clean --force
Simple solutions:
npm cache clean --force
npm install
This command alone solved my problem:
npm cache clean --force
Also you should make sure you are using the correct version of node.
Using nvm to manage the node version:
nvm list; # check your local versions;
nvm install 10.10.0; # install a new remote version;
nvm alias default 10.10.0; # set the 10.10.0 as the default node version, but you have to restart the terminal to make it take effect;
I use Windows and removed all the files that were listed below and my problem was solved
C:\Users{{your-username}}\AppData\Roaming\npm-cache
npm cache clean --force worked for me
Error Resolved :
$ npm install -g gulp
npm WARN deprecated gulp-util#3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm ERR! Unexpected end of JSON input while parsing near '.../RGs88STtAtiMP3tCiNdU'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache_logs\2018-11-20T07_38_56_733Z-debug.log
Solution
npm cache clean --force
For Windows : go to C:\Users\username\AppData\Roaming\npm-cache
Delete all files and run
npm install && npm start
I solved that by first cleaning the cache using
npm cache clean --force
Then
npm install -g #angular/cli
My case - Windows 7 (had nothing better at the needed moment).
Helped me the following:
Deleting everything from C:\Users\username\AppData\Roaming\npm-cache
AND
Deleting package-lock.json
I resolved my problem with this one liner
npm cache clean --force
Note: since its a clean install, I had no concerns emptying npm cache.
ERROR: npm ERR! Unexpected end of JSON input while parsing near '...ore-js":"3.0.0-beta.1
This occurs when installing the expo CLI globally, This works for me!
npm cache clean --force
I got error (file already exists --force to overwrite) after running the following code:
npm cache clean --force
npm install -g #angular/cli
I solved it using :
npm i -g --force npm
Make sure to run the first commands to flush the cache of npm.
It's error from your npm....
So unistall node and install it again.
It works....
PS: After installing node again, install angular cli globally.
npm install -g #angular/cli#latest
I solve that with
First delete package-lock.json
npm cache clean --force
then update npm
npm i npm#latest -g
then use npm install command
npm install
If you looking for npm install and getting same kind of error
Delete package-lock.json and npm cache clean --force and try
In my case I changed the network to a much stronger one and npm install worked perfectly:
npm cache clean --force
If npm cache clean --force doesn't resolve the issue, try deleting the ~/.npm directory (*nix/macOS). This is the directory where node stores its cache, locks, logs, global packages (unless you're using nvm), and modules installed via npx.
First, backup your current ~/.npm directory:
mv ~/.npm ~/.npm-backup
Now try running your npm command again. This will create a new ~/.npm directory. If the issue is resolved, you can safely remove you backup. Before doing so, you may want to review the global packages installed in your ~/.npm-backup directory so you can reinstall them using npm i -g [package].
rm -rf ~/.npm-backup
If the issue is not resolved, you can restore your backup:
rm -rf ~/.npm
mv ~/.npm-backup ~/.npm
Careful with those rm commands, folks!
Instead of clearing the cache you can set a temporary folder:
npm install --cache /tmp/empty-cache
or
npm install --global --cache /tmp/empty-cache
As of npm#5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use npm cache verify instead. On the other hand, if you're debugging an issue with the installer, you can use npm install --cache /tmp/empty-cache to use a temporary cache instead of nuking the actual one.
For me I had to clone my branch again and do npm install
You can use yarn package manager instead of npm.
It solved this problem for me
I've faced this issue and I tried all the answers on Stackoverflow but not worked for me, finally I found solution for this issue:
First of all you have to uninstall nodejs and remove all the files related him
Go to "Register Editor" and search for all "nodejs", "node.js" and delete them
Restart your computer
And reinstall nodejs then install angular.
It's worked for me
These commands worked for me
sudo npm cache clean --force
sudo npm cache verify
sudo npm i npm#latest -g
Try setting
npm config set strict-ssl false
and then try running,
npm install -g #angular/cli
This happens something due to cache or outdated version of Node Package Manager
i just updated my NPM it works fine
here is command to update Npm to latest version
npm i npm#latest -g
after updating NPM run your desired command

Local grunt installation gives error

npm install -g grunt-cli //done successfully
npm install grunt --save --only=dev
gives following error
(node:11000) fs: re-evaluating native module sources is not supported. If
you are using the graceful
-fs module, please update it to a more recent version.
npm WARN prefer global coffee-script#1.10.0 should be installed with -g
project#1.0.0 C:\Users\Live\Desktop\node grunt\final
`-- (empty)
npm WARN project#1.0.0 No repository field.
npm ERR! code 1
Tried uninstalling grunt-cli, cleaning npm cache, then re-installing, but still the problem persists.
Ok short recap:
When in doubt remove your node_modules and install all packages again using npm install
If that didn't work, try updating your npm by executing npm update -g npm and redo step 1.
If that didn't solve your problem, try upgrading to another NodeJS version using nvm or n.

Resources