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 · 21 comments
Closed

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

changjunhao opened this issue Jun 1, 2018 · 21 comments

Comments

@changjunhao
Copy link

@changjunhao changjunhao commented Jun 1, 2018

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

This comment has been minimized.

Copy link
Collaborator

@troy0820 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 Jun 1, 2018
@ozjd

This comment has been minimized.

Copy link

@ozjd ozjd commented Jun 5, 2018

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

See npm/npm#20848 (comment)

@Norbz

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

@mateodelnorte mateodelnorte commented Jun 22, 2018

I am still getting this issue.

@rosshadden

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

@mateodelnorte mateodelnorte commented Jun 22, 2018

@deksden

This comment has been minimized.

@Andrewsopoku

This comment has been minimized.

Copy link

@Andrewsopoku Andrewsopoku commented Jul 4, 2018

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

@rosshadden

This comment has been minimized.

Copy link

@rosshadden rosshadden commented Jul 13, 2018

@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

This comment has been minimized.

Copy link
Collaborator

@shadowspawn shadowspawn commented Jul 18, 2018

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

@prcongithub

This comment has been minimized.

Copy link

@prcongithub prcongithub commented Sep 4, 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
@designgawd

This comment has been minimized.

Copy link

@designgawd designgawd commented Sep 11, 2018

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

@shengoo

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

@deksden deksden commented Sep 23, 2018

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

@shadowspawn

This comment has been minimized.

Copy link
Collaborator

@shadowspawn shadowspawn commented Sep 24, 2018

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
+ n@2.1.12
updated 1 package in 0.466s
@PepperTeasdale

This comment has been minimized.

Copy link

@PepperTeasdale PepperTeasdale commented Oct 18, 2018

@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

This comment has been minimized.

Copy link
Collaborator

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

@PepperTeasdale

This comment has been minimized.

Copy link

@PepperTeasdale PepperTeasdale commented Oct 18, 2018

Thanks!

PepperTeasdale added a commit to PepperTeasdale/homebrew-core that referenced this issue Oct 19, 2018
This patch fixes a bug as seen in this [github issue](tj/n#508)
@PepperTeasdale PepperTeasdale mentioned this issue Oct 19, 2018
4 of 4 tasks complete
BrewTestBot added a commit to BrewTestBot/homebrew-core that referenced this issue Oct 19, 2018
This patch fixes a bug as seen in this [github issue](tj/n#508)
fxcoudert added 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 <fxcoudert@gmail.com>
@mrzmyr

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Collaborator

@shadowspawn shadowspawn commented Mar 12, 2019

Good comment @mrzmyr

See #508 (comment) for more complete instructions.

@gerenrot

This comment has been minimized.

Copy link

@gerenrot gerenrot commented Aug 26, 2019

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.