Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"npm install xyz" produces "asyncWrite is not a function" #508

Closed
changjunhao opened this issue Jun 1, 2018 · 22 comments
Closed

"npm install xyz" produces "asyncWrite is not a function" #508

changjunhao opened this issue Jun 1, 2018 · 22 comments

Comments

@changjunhao
Copy link

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

@troy0820
Copy link
Collaborator

troy0820 commented Jun 1, 2018

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.

@troy0820 troy0820 closed this as completed Jun 1, 2018
@realJoshByrnes
Copy link

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

See npm/npm#20848 (comment)

@Norbz
Copy link

Norbz commented Jun 14, 2018

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

@mateodelnorte
Copy link

I am still getting this issue.

@rosshadden
Copy link

rosshadden commented Jun 22, 2018

@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.

@mateodelnorte
Copy link

mateodelnorte commented Jun 22, 2018 via email

@deksden
Copy link

deksden commented Jun 25, 2018

@Andrewsopoku
Copy link

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

@rosshadden
Copy link

@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.

@shadowspawn
Copy link
Collaborator

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

@prcongithub
Copy link

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

@designgawd
Copy link

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

@shengoo
Copy link

shengoo commented Sep 22, 2018

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!

@deksden
Copy link

deksden commented Sep 23, 2018

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

@shadowspawn
Copy link
Collaborator

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

@jtschulz
Copy link

@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

@troy0820
Copy link
Collaborator

troy0820 commented Oct 18, 2018

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

@jtschulz
Copy link

Thanks!

jtschulz added a commit to jtschulz/homebrew-core that referenced this issue Oct 19, 2018
This patch fixes a bug as seen in this [github issue](tj/n#508)
fxcoudert pushed a commit to Homebrew/homebrew-core that referenced this issue Oct 19, 2018
This patch fixes a bug as seen in this [github issue](tj/n#508)

Closes #33153.

Signed-off-by: FX Coudert <[email protected]>
@mrzmyr
Copy link

mrzmyr commented Mar 12, 2019

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.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Mar 12, 2019

Good comment @mrzmyr

See #508 (comment) for more complete instructions.

@gerenrot
Copy link

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 #510 (comment)

@AchintyaAshok
Copy link

#508 (comment)

After you do this, go to https://nodejs.org/en/ and reinstall node. Then, install a node package manager like n => npm install -g n.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests