When run `npm install` got outputs: npm ERR! asyncWrite is not a function

triaged
cli

(Lei) #1

What I Wanted to Do

Run npm install command to install packages.

What Happened Instead

It got npm ERR! asyncWrite is not a function outputs.

Reproduction Steps

Run npm install under a Node.js project or npm install <package-name> to install some packages.

Details

I am trying to run npm install command to install packages, but got failed.

I can see the npm debug log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'i' ]
2 info using npm@6.4.1
3 info using node@v10.15.0
4 verbose npm-session 8dc51bd40ea047d5
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall @modernjs/send@1.0.0
7 info lifecycle @modernjs/send@1.0.0~preinstall: @modernjs/send@1.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 18ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 89ms
16 silly install loadAllDepsIntoIdealTree
17 verbose stack TypeError: asyncWrite is not a function
17 verbose stack     at onwrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:480:7)
17 verbose stack     at WritableState.onwrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:180:5)
17 verbose stack     at WriteStream.to [as _worker] (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:154:13)
17 verbose stack     at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
17 verbose stack     at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
17 verbose stack     at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
17 verbose stack     at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
17 verbose stack     at WriteStream.to [as _worker] (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:171:25)
17 verbose stack     at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
17 verbose stack     at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
17 verbose stack     at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
17 verbose stack     at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
17 verbose stack     at WriteStream.to [as _worker] (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:182:19)
17 verbose stack     at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
17 verbose stack     at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
17 verbose stack     at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
18 verbose cwd /Users/glen/work/open/@modernjs/send
19 verbose Darwin 18.2.0
20 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i"
21 verbose node v10.15.0
22 verbose npm  v6.4.1
23 error asyncWrite is not a function
24 verbose exit [ 1, true ]

Platform Info

$ npm --versions
{ '@modernjs/send': '1.0.0',
  npm: '6.4.1',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.0',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.45',
  zlib: '1.2.11' }

$ node -p process.platform
darwin

(John Gee) #2

This can happen with a damaged npm install, in particular when the new version was copied over the top of an existing install without removing it first.

In general, reinstalling is likely to fix it:
https://docs.npmjs.com/common-errors#broken-npm-installation

In particular, if you are using n to manage your node versions, there was an issue fixed earlier this year:
https://github.com/tj/n/issues/508#issuecomment-423933394


(Kat Marchán) #3

This is a duplicate of asyncWrite is not a function at node@10.3.0 and npm@6.1.0


(Kat Marchán) #4