How to resolve (reading 'isServer') error in npm? - node.js

Catch this error after npm i. Version npm - 8.0.0, nodejs - 16.11.0.
npm ERR! Cannot read properties of undefined (reading 'isServer')

I had the same issue with close versions of node and npm. I was using a shared connection from my phone since I wasn't home. When I get back home and used my WiFi things got back to normal.
If you are using such kind of connection then it is probably that causes this issue.

Try to use npm with specific version
for example i was trying to use npm install -g truffle and it did not work
but this one work npm install -g truffle#5.0.5

I updated npm and that fixed it!
You can update npm like so:
npm install -g npm#latest
If running this command doesn't work then you can try installing npm packages in an Admin Environment.
Hope this helps!

The issue could be due to the network, try to change the network and retry. This solved my issue :)

I've got the same issue, then I updated npm to 8.3.0, and the problem is solved.

Copying the npmrc.5 file from:
C:\Program Files\nodejs\node_modules\npm\man\man5 to C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm seemed to work for me:
Copy-Item -Path C:\Program Files\nodejs\node_modules\npm\man\man5 -Destination C:\Users\Administrator\AppData\Roaming\npm\node_modules\npm –Passthru

Try stable Nodejs version 14.16.1 instead of 16.
Nodejs 14.16.1 Link

Update the latest version of Node.js. Then try to install npm the issue won't come.
Check out this URL https://nodejs.org/en/
and install a version recommended for most users.

I had this same issue, turning off all port forwarding on my router helped.

Whenever, I saw this problem. I restarted the computer and it working immediately.
I recommend trying this solution.

Based on what I've read on issues related, it seems like there's conflicting global packages and node versions.
Please try uninstalling both node and npm and try again.
Check out these issues for more details:
Node error Cannot read property 'resolve' of undefined
Cannot read property 'resolve' of undefined when using npm to install a package

I had the same issue and tried all the possible solutions. None of them worked.
And finally, when I restarted my PC, it worked like a charm :).

It happened to me because of the node.js version and an npm update.
Uninstall nodejs
Delete folder C:\Users\Administrator\AppData\Roaming\npm
Install nodejs (v17.x)
In your project folder:
npm install -g npm#8.3.2
npm i --package-lock-only
npm audit fix --force
It worked for me. I hope it helps you :)

When I had this problem, I was trying to deploy my NodeJs server in Heroku. The problem was I forgot to load the enviroment variables manually, so it was related to the connection to the DB, that was failing.
It happened also locally for the same reason and it was still related to the failing connection to the DB.

I kept running into this problem in different scenarios. I found that because I had used a VPN during my computer session, but not during the time I ran 'npm install', it was throwing this error. I simply reinstalled and restarted and did not enable my VPN during that session. Although, you may not have to completely reinstall-- only restart you PC without using a VPN after restart-- I do not know as I have not tried.
(Specifically I was using Express VPN)
Update: I ran into the problem again immediately after a fresh install and restart. Again I restarted my computer (without a fresh install as I had just reinstalled it.) This seemed to work for the moment. Will update with any permanent fixes I come across.

Related

npm install always ETIMEOUT can's fix

I have spent my whole day on fixing this problem but can't see any light.
My node and npm version is below
And no matter what package I wanna install, it always show
I am sure that I am not in any proxy and I have already lower my node version from 18 to 14,
but the problem still exist!!!!
Could anyone know how to fix this problem help me?
I already tried every way to fix this but can't work.
Since when did the issue start? Did it occur after you installed any dependency or made any proxy / firewall related configurations?
However you can try one of the following ways to fix this issue
Delete node_modules folder and in terminal, write
npm install
Change your nodejs version, either upgrade it or downgrade it
Reinstall nodejs
Try some other package manager like yarn
Note: When changing your nodejs version, please ensure that your node version is compitable with the npm version
Edit:
If these solutions don't work, the error is most probably caused by network related issues, you can try the following fixes
In terminal, reset the registry path of your node package manager
npm config set registry http://registry.npmjs.org/
If you are using your organization's computer, you need to use a proxy, remember to change the proxy url and port as per your organization
npm config set proxy http://proxyurl.com:8080
npm config set https-proxy http://proxyurl.com:8080
Instead of local installation, try installing packages globally i.e
npm install -g mongoose
Clear the cache
npm cache verify
Switch your device to some other wifi network and then try installing some npm packages

Different NPM version used when generating React app

When I try to create the starter React tutorial app using powershell, I get the below error:
"You are using npm 2.15.12 so the project will be boostrapped with an old unsupported version of tools".
"Please update to npm 3 or higher for a better, fully supported experience".
However, my NPM version is 6.11.3 as seen below.
What I have tried:
I have ran powershell as admin as answered in this question and restart.
I have also uninstalled and reinstalled Nodejs completely.
So after an extra hour digging around, I saw a few posts with similar (but not exactly) the same issue. I decided to install Yarn and install with that.
After install, I ran yarn cache clean and ran npx create-react-app your-app and it worked. Sorry for bothering you all.
I had the same problem. I'm running WSL with ubuntu, and yarn cache clear didn't work, but I noticed a node modules directory created in the project. I think it was messing with the node version so I deleted it. It worked

When using 'npm' it requires me to login to github

Problem When i try to use npm in any way, ex: npm update or npm i package it immediatly gives me a github login prompt.
What i tried using npm with i, install, and even giving it git directly git://. But none worked sadly.
I am new to Node.js. So far (2 weeks), i have been updating, installing and reinstalling dependencies without a problem. Just now this issue occured.
What i was doing before the error occured was nothing special. Just programming. Last thing i used npm for was to install discord.js npm i discord.js.
Thank you in advance.
to have such a problem, it means your command is wrong. take for example you are trying to install angular cli and you omit the # symbol login will pop like so
npm install -g angular/cli // this will trigger login pop-up
npm install -g #angular/cli // will work fine
so check your command
This issue has been resolved. The problem was very simple but i couldn't figure it out at first.
So what was wrong with my issue here was that i accidently while working on my project changed a value in the "Package.json" file. This is ofcourse not intended. With that, my whole project's 'npm' command was broken where it could't work anymore.
Thank you everyone for your time.

Can't install firebase-admin with npm

I'm trying to run this command to install firebase-admin: npm install firebase-admin --save
When I try to run this command, I get the following error:
ENOENT: no such file or directory, rename 'D:\MyPath\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\abbrev' -> 'D:\MyPath\functions\node_modules\firebase-admin\node_modules\grpc\node_modules\.abbrev.DELETE'
I have tried reinstalling Node.js, I have tried uninstalling a previous version of Node.js, I have tried updating npm, I have tried pretty much everything online but nothing is helping. If I run the newest version of Node.js, instead of getting this error, I get the following error:
Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
I have honestly tried several GitHub threads for people with the same problem but none of their solutions have worked for me, so I am trying here. Can anybody help me with this issue?
Upon further tinkering with this, it looks like I finally solved my issue so i can finally deploy to Firebase. These are the steps I took to solve this problem:
First, I uninstalled firebase-admin using the npm uninstall firebase-admin command.
I reinstalled firebase-adming using the npm install firebase-admin command. This didn't seem to fix my issue, but you never know.
I deleted the firebase-admin directory in the node_modules directory.
I ran npm install
I installed the firebase-admin directory again, this time using npm install firebase-admin --save
I ran firebase deploy and it worked!
I don't know how many of those steps were truly necessary but in the end, it worked.
Try to install it using yarn it will get installed smoothly as I faced the same issue while using npm I ran
yarn add firebase-admin and it got easily installed

can't update npm (missing access)

Breaking my head to get over that error. I've tried every forum but still I can't find a proper solution. I also uninstalled and reinstall npm and still same issue.
Please save me!
npm error
and also
log
ta!
Just a wild guess:
remove .npm-modules in your home folder
remove modules from the project you are using
npm install, all should be fine
Use homebrew to install npm and nodejs. Write the command as shown below:
brew install node . Once it is successfully installed check it with node -v.
For more details you can go through this tutorial

Resources