npm i not working? npm ERR! Unexpected token '.' - node.js

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.

Related

npm ERR! Cannot read properties of null (reading 'pickAlgorithm')

iam getting below error with npm while creating react app
npm ERR! Cannot read properties of null (reading 'pickAlgorithm')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nagamanickam\AppData\Local\npm-cache_logs\2021-11-18T12_01_45_525Z-debug.log
my npm version is 8.1.4 and i solve this problem by running :
npm cache clear --force
I resolved it by deleting node_modules and package-lock.json and run npm install again.
solved with npm i --legacy-peer-deps on react-native version .70
Just run these 2 commands :
npm cache clear --force
npm install
Probably it's a project that works with Yarn and not NPM.
Try Yarn instead of NPM.
yarn install
and then you can do
yarn start
or
npm start
Your dependency tree may be broken (due to incompartible peer dependencies) you can try running npm install with --legacy-peer-deps or --force to bypass this issue for the mean time.
I was getting this error from an old branch that had a previous version of node/npm. using the correct version of node helped in my case.
In my case the file .npmrc was corrupt. After deleting it everything worked.
I was getting the same error, but I was able to resolve it by the below described method:
Go to folder -> Local > npm-cache and delete all contents of the npm-cache.
try again with npm command, it should work now.
I solved this by update npm from 6.x to 8.5x, then run npm cache clear --force, npm install, however, it has to change the nodejs from 14 to 17, my env is macOS m1 pro.
In my case i updated npm via:
npm update -g npm
After it, everything worked fine.
Don't know why, i didn't expect it.
I solved deleting node_modules and running this command:
npm cache clear --force

how do I resolve this node-sass installation error

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.

npm package getting installed but not working

when I am using command npm install -g lerna it gets executed with no error but after that using command
lerna --version gives output "lerna:command not found".
Possible solution
maybe if somehow I manage it to install in usr/local/lib/node_modules it should work cause other npm packages installed here are working fine but its getting installed in /home/surajkulriya/.npm-global/lib/node_modules.
OS: ubuntu 18.04
which npm:/usr/local/bin/npm
which node:/usr/local/bin/node
which nodejs:/usr/bin/nodejs
Finally after too much effort I sorted out the issue. I removed node nodejs and npm completely and reinstalled them again and used command
npm i -g npm
to fix the broken dependecies.I reinstalled lerna and it worked.

Error('`libsass` bindings not found. Try reinstalling `node-sass`?') using node-sass running ionic

I updated my npm and ionic yesterday and my ionic project that was originally working is giving me this error.
Error('`libsass` bindings not found. Try reinstalling `node-sass`?');
I tried
sudo npm install node-sass
sudo npm -g install node-gyp
sudo npm rebuild node-sass
but it did not work. Any help would be appreciated.
Never use sudo with npm. You will have lot of problems with permissions if you do that. And for your issue, this helped me:
npm cache clean && node ./node_modules/node-sass/scripts/install.js
Try also removing all node modules before that (whole folder), run npm install (without sudo) and then if it doesn't work run the command that I wrote.

NPM Install is not installing dependencies

I'm attempting to install the Ushahidi V3 Client. I've been following the install process up until when I need to build the project from the source repo using npm and gulp - both of which I've had zero experience with. Whenever I run sudo npm install in the project directory, the process runs without complaints. However, when I run npm ls to verify that dependencies have been downloaded, I get a bunch of dependencies listed out as being missing.
How do I get npm to resolve all of these dependencies?
System Details
OS Ubuntu 14.04 (Trusty)
Node JS v0.12.9
NPM v3.5.1
What I've tried
Removing node_modules folder and re-running sudo npm install as referenced in this SO answer for a similar question: npm Gulp dependencies missing, even after running npm install
Uninstalling and reinstalling node and npm
#Strainy, as your research :D
It was a combination of running as sudo and not having the build-essentials.
That's why you should not use sudo npm
Follow these steps:
try npm uninstall. and then try npm install.
Also If it still doesn't work.
Try:
npm install -g npm-install-missing
or
npm-install-missing
For further reading, click here.

Resources