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

cli

(Kiko Beats) #1

What I Wanted to Do

Just do npm install under node@10.3.0 and npm@6.1.0 (included by default)

What Happened Instead

The process log a npm ERR! asyncWrite is not a function all the time

Reproduction Steps

I think my code is not significant here, but I see the error doing a npm install after clone https://github.com/microlinkhq/www.

A complete npm debug stack trace here:

Extra information

If I switch to node@10.2.1 that has npm@5.6.0, it works like a charm.

Then the thing that was trying to do was update npm to the last version.

I can’t update npm from node@10.3.0 because the process throws another error related with stream:

npm ERR! pna.nextTick is not a function

so instead I downgrade to node@10.2.1 and install the last npm version available

The last npm version available is npm@6.1.0, that is curious because is the same that the npm version included in the node@10.3.0 bundle :thinking:

But this time it works fine. Looks like node@10.3.0 include a breaking change related with stream under the hood and the npm process doesn’t like it.

Details

❯ node --version
v10.3.0

❯ npm --version
6.1.0

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
NPM install not working at all for anything
(William Blankenship) #3

I’m experiencing the same thing after an n install 10.3.0

The first install appeared to crash after the asyncWrite failed, the second onward appears to chug along and hits other errors as well, including cache misses and a pna.nextTick is not a function

$ lsb_release -a
|Distributor ID:|Trisquel|
|---|---|
|Description:|Trisquel GNU/Linux 8.0, Flidas|
|Release:|8.0|
|Codename:|flidas|
$ node --version
v10.3.0
$ npm --version
6.1.0
$ 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/retrohacker/.npm/_logs/2018-06-05T19_53_43_635Z-debug.log
$ npm install
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! 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! 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
Unhandled rejection Error: No cache entry for pacote:packed-dir: found in /home/retrohacker/.npm/_cacache
    at index.find.then.entry (/home/retrohacker/n/lib/node_modules/npm/node_modules/cacache/get.js:83:18)
    at tryCatcher (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:696:18)

Unhandled rejection Error: No cache entry for pacote:packed-dir:git+ssh://git@github.com/[redacted].git#[redacted] found in /home/retrohacker/.npm/_cacache
    at index.find.then.entry (/home/retrohacker/n/lib/node_modules/npm/node_modules/cacache/get.js:83:18)
    at tryCatcher (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:696:18)

npm ERR! pna.nextTick is not a function
Unhandled rejection Error: No cache entry for pacote:packed-dir:git+ssh://git@github.com/[redacted].git#[redacted] found in /home/retrohacker/.npm/_cacache
    at index.find.then.entry (/home/retrohacker/n/lib/node_modules/npm/node_modules/cacache/get.js:83:18)
    at tryCatcher (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
    at Promise._resolveCallback (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:432:57)
    at Promise._settlePromiseFromHandler (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:524:17)
    at Promise._settlePromise (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/retrohacker/n/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:696:18)

[CTRL-C INTERRUPT]

(Andrew Ellis) #4

This appears to be fixed using node@10.4.0 and npm@6.1.0.

[app git:(develop)] ✔  node -v
v10.4.0
[app git:(develop)] ✔  npm -v
6.1.0
[app git:(develop)] ✔  npm install
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

audited 20323 packages in 8.246s
found 17 moderate severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

(Kat Marchán) #5

I’m gonna assume this was just a node bug, then. :slight_smile:


(Susenbeth) #6

I´ve still got this problem even with the latest versions of npm and node.

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

How can i get around this?


(Brandon Pittman) #8

I’m getting this on 10.4 and 6.1. So, no, it’s not fixed with Node 10.4.


(Kat Marchán) #9

This one is super weird. I have no idea why y’all would be getting either a missing setImmediate or why process would be missing nextTick?

I think y’all can probably do some spelunking on this one. It’s definitely a bug in readable-stream, and possible process-nextick-args. Would be super helpful if someone with the repo looked into it.

I’m putting this back as unresolved in the meantime.


(Brandon Pittman) #10

Well, I was using a node version manager instead of node through homebrew starting yesterday. I just dropped the version manager, went back to brew, and now the installs are working again.


(Kat Marchán) #11

That is super weird.


(Brandon Pittman) #12

My sentiments exactly.


(Victor Redondo) #13

I’m getting the same issue node 10.4 npm 6.1.
I used n to manage the node versions in my mac, this issue start raising after I installed latest node version n latest


(Kat Marchán) #14

Someone should also file an issue with readable-stream itself. Not sure how we can fix it npm-side yet.


(Rebecca Turner) #16

I’m thinking this is a bug in how some version managers switch versions. Looking at the n source:

It’s activate code copies node to to its destination:

cp -fR “$dir/$subdir” $N_PREFIX

Because npm is now installed flatter than it was in previous version, this means that just copying like that is going to completely break your install. (Because w/o the remove, the older deeply nested versions will remain in place and you’ll get the wrong version of modules.) You need to remove the existing version before copying the new one in.

Folks who are seeing this issue, can you chime in with how you’re installing node, like, specifically which version manager, if you’re using one? (I use nvm, it doesn’t have this issue, fwiw.)


(Kiko Beats) #17

I’m using n, but I didn’t see this kind of errors in other previous version :thinking:


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
(Rebecca Turner) #18

@kikobeats That’s not surprising: We started flattening the npm tree with 10.3.0, due to Node.js fixing a similar bug in the official installers this past February.


(Rebecca Turner) #19

I’ve opened an issue: https://github.com/tj/n/issues/510 (I can reproduce this with n.)


(Rebecca Turner) #20

This has been fixed with a new release of n! =)


(Kat Marchán) #22

(Rebecca Turner) #23