N: "npm install xyz" produces "asyncWrite is not a function"

Created on 1 Jun 2018  Â·  21Comments  Â·  Source: tj/n

Issue Template:

Describe issue including what OS you are using

I'm using CentOS

Describe what version of N you have

--version output: 2.1.11

Describe how you installed N

npm install -g n_

Steps to reproduce issue _1.2.3_

_i.e._

  1. n latest

What version of npm you are using

npm --version output: 6.1.0

Additional information you deem important (e.g. issue happens only occasionally):

  • Output of which n: 2.1.11
  • Output of node -v: 10.3.0

(paste your output here)

2018-06-01 11 50 34

Most helpful comment

This woks for me:

rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/bin/node
rm -rf /usr/local/bin/npm
n 10.9.0
node -v
npm -v

All 21 comments

I tried this in a docker container and reproduced the same error. I looked around within npm because this isn't an N issue. I found these issues: pna.nextTick and this one. I'm going to close this issue but the solution I had was to use node 8.11.2 with npm version 5.6.0 to solve this issue.

Had the same issue, reverting to stable, updating npm, then upgrading node to latest worked for me.

See https://github.com/npm/npm/issues/20848#issuecomment-394680906

@ozjd linked solution worked for me
Seems to be a bug with 'n' indeed. Node 10.3 and 10.4 have the same issue

I am still getting this issue.

@mateodelnorte Did you try what @ozjd linked above? It worked for me.
Not that n shouldn't try to fix it if applicable, of course.

I was actually able to revert back to lts, upgrade n, switch to 10, and
then publish.

Thanks!

On Fri, Jun 22, 2018, 7:49 AM Ross Hadden notifications@github.com wrote:

@mateodelnorte https://github.com/mateodelnorte Did you try what @ozjd
https://github.com/ozjd linked above? It worked for me.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/tj/n/issues/508#issuecomment-399431218, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAh3X75K-83TTU6d_k3WjVlHo5EYgppfks5t_OeqgaJpZM4UWD6j
.

Use sudo when switching node version with n
example sudo n 10.4.1

@Andrewsopoku That would switch the n version for the root user, not for your user... Unless you have n configured very strangely it won't actually solve or even bypass the issue.

This has been fixed in latest version of n. (See Issue #510 for and PR #470 for further info.)

This woks for me:

rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/bin/node
rm -rf /usr/local/bin/npm
n 10.9.0
node -v
npm -v

@prcongithub That was the solution I was looking for! Thanks, worked in my VM.

This woks for me:

rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/bin/node
rm -rf /usr/local/bin/npm
n 10.9.0
node -v
npm -v

Thanks, it worked!

Maybe some way of complete uninstall of all node versions (like mentioned above) can be part of n?

n was updated in v2.1.12 to address this issue, which is due to major changes in layout in the npm modules folder. So an important step in addition to fixing npm is to also update n, so the problem does not happen again. For example to fix up broken npm and update n (add sudo if required):

$ rm /usr/local/bin/node
$ rm -rf /usr/local/lib/node_modules/npm
$ n latest
$ npm --version
6.4.1
$ npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ [email protected]
updated 1 package in 0.466s

@JohnRGee I'm not seeing v2.1.12 in the releases. Would it be possible to make a release for this version so the homebrew version of n can be bumped? https://github.com/Homebrew/homebrew-core/blob/master/Formula/n.rb

Bumped into this issue the other day and it took me a while to find this as the root cause

Yeah, I'll make a new release for 2.1.12

-- edit: npm shows 2.1.12 but I tagged it on github so you can get the latest @PepperTeasdale

Thanks!

This woks for me:

rm -rf /usr/local/lib/node_modules
rm -rf /usr/local/bin/node
rm -rf /usr/local/bin/npm
n 10.9.0
node -v
npm -v

If you remove all global npm packages it's not possible for me to use n anymore.

Good comment @mrzmyr

See https://github.com/tj/n/issues/508#issuecomment-423933394 for more complete instructions.

This worked for me on CentOS without having to reinstall node:
$(dirname $(n which $(node -v)))/npm i -g npm

It's based on @iarna one liner here https://github.com/tj/n/issues/510#issue-330786549

Was this page helpful?
0 / 5 - 0 ratings