On clean node v10.5.0, v10.6.0 and v10.7.0 install, npm install yelds asyncWrite is not a function and pna.nextTick is not a function

cli
priority:low
triaged

(Trygve Lie) #1

This bug was also reported here: https://github.com/npm/npm/issues/21049

This is not the same as asyncWrite is not a function at node@10.3.0 and npm@6.1.0 since there is no install manager like n etc involved. This is with clean install of node and the npm version shipped with node.

These issues has also been reported to node.js which closes it and points to npm having an issue. I see npm blaming node here and pointing to them. Iow: both are pointing to each other.

What I Wanted to Do

Download node v10.5.0 or v10.6.0 on a clean Ubuntu and installing npm modules in a project.

What Happened Instead

Clean install of node version 10.5.0 / 10.6.0 on Ubuntu 17.10. NB: I am not using n or any other node install managers.

Node is installed by downloading the official tar file then compiled and installed with the following:

./configure
make
make install

When running npm install in any module the following is yeld and nothing gets installed:

npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! asyncWrite is not a function
npm ERR! pna.nextTick is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/trygve/.npm/_logs/2018-06-22T12_37_57_401Z-debug.log

Have tried to delete global cache and removed node_modules folder in the modules I’m installing in without any effect on the issue.

Reproduction Steps

Install node v10.5.0 / 10.6.0 on a clean Ubuntu machine, then run npm install in any module which has dependencies.

Details

Output of npm log file:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'install' ]
2 info using npm@6.1.0
3 info using node@v10.5.0
4 verbose npm-session 74c70565c1c3bb8b
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall ttl-mem-cache@4.0.0
7 info lifecycle ttl-mem-cache@4.0.0~preinstall: ttl-mem-cache@4.0.0
8 silly install loadCurrentTree
9 silly install readLocalPackageData
10 timing stage:loadCurrentTree Completed in 9ms
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 1ms
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 /home/trygve/Dev/ttl-mem-cache
19 verbose Linux 4.13.0-45-generic
20 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
21 verbose node v10.5.0
22 verbose npm  v6.1.0
23 error asyncWrite is not a function
24 verbose exit [ 1, true ]

Platform Info

$ npm --versions
6.1.0
$ node -p process.platform
v10.5.0

(Trygve Lie) #2

On node v10.7.0 this is worse. Clean install of node v10.7.0 and then an install in any module yelds:

npm install
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.r /home/trygve/Dev/ttl-mem-cac
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
npm[2247]: ../src/node_zlib.cc:436:static void node::{anonymous}::ZCtx::Init(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
 1: 0x5625547ab8c0 node::Abort() [npm]
 2: 0x5625547ab9b8  [npm]
 3: 0x562554851656  [npm]
 4: 0x562554a692a9  [npm]
 5: 0x562554a6a234 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [npm]
 6: 0xfde019841bd 
Aborted (core dumped)

npm --version yelds v6.1.0. Iow; the shipped npm version in node v10.7.0 is not compatible with node v10.7.0.

When trying to update to npm version v6.2.0 the following erros:

 npm install -g npm
npm ERR! asyncWrite is not a function
npm ERR! pna.nextTick is not a function

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/trygve/.npm/_logs/2018-07-19T12_28_23_791Z-debug.log

Rendering it impossible to install anything.

Content of 2018-07-19T12_28_23_791Z-debug.log is:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   'npm' ]
2 info using npm@6.1.0
3 info using node@v10.7.0
4 verbose npm-session 2ffdc5a376faeba2
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 verbose stack TypeError: asyncWrite is not a function
7 verbose stack     at onwrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:480:7)
7 verbose stack     at WritableState.onwrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:180:5)
7 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)
7 verbose stack     at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack     at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack     at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
7 verbose stack     at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
7 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)
7 verbose stack     at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack     at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack     at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
7 verbose stack     at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
7 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)
7 verbose stack     at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack     at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack     at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
8 verbose cwd /home/trygve/Dev/ttl-mem-cache
9 verbose Linux 4.13.0-46-generic
10 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "npm"
11 verbose node v10.7.0
12 verbose npm  v6.1.0
13 error asyncWrite is not a function
14 verbose exit [ 1, true ]

(Kat Marchán) #3

This is bizarre. Is Ubuntu messed up or something? Have you already tried Installing/upgrading npm


(Kat Marchán) #4

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


(Trygve Lie) #5

If I manually remove my /usr/local/lib/node_modules/npm/ folder and run make install with node v10.7.0 it seems to work.

To me it seems like some deduping have gone wrong causig a not compatible version readable-stream to be used by npm.


(Kat Marchán) #6

Ugh. I was rushing through triage last night and missed that it was not a duplicate. My bad.


(Commenthol) #7

I encounter the same problem with node@10.x and npm@6.x again and again.
The issue seams related with how ‘readable-streams’ uses ‘process-nextick-args’
Something is different here compared to node@8.x as pna.nextTick becomes undefined somewhere.
No idea so far. Maybe module.exports = process in ‘process-nextick-args’ is not a good idea?
My workarround is to disable ‘readable-streams’ with in .bashrc

export READABLE_STREAM=disable

To whom it may concern…

Setting lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:57

/*<replacement>*/
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : process.nextTick; // instead of `pna.nextTick`
/*</replacement>*/

works as well. This looks that something with requiring ‘process-nextick-args’ is broken in node@10.x …


(Commenthol) #8

Btw. readable-streams@3 does not use module “process-nextick-args” anymore see https://github.com/nodejs/readable-stream/pull/354 - maybe npm could bump dependencies?


(SneakyFish5) #9

Nice @commenthol figuring out that updating readable-stream will fix this. I’ve opened a PR here to update it to latest version.


(system) #10

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.