How to resolve (reading 'isServer') error in npm?

Viewed 11331

Catch this error after npm i. Version npm - 8.0.0, nodejs - 16.11.0.

npm ERR! Cannot read properties of undefined (reading 'isServer')
13 Answers

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!

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

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.

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.

  1. Uninstall nodejs
  2. Delete folder C:\Users\Administrator\AppData\Roaming\npm
  3. Install nodejs (v17.x)
  4. 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 :)

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