This repository has been archived by the owner. It is now read-only.

npm install fails with "Error: write after end" or "ERR_STREAM_WRITE_AFTER_END" on 5.7.x and 5.8.x #19989

Closed
deployable opened this Issue Mar 7, 2018 · 99 comments

Comments

Projects
None yet
@deployable
Contributor

deployable commented Mar 7, 2018

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

An npm install is failing on npm 5.7.x during extraction of larger projects, most of the time. The issue appears to be related to the update of pacote in 5.7.0: zkat/pacote#142

v8.9.4

7420 silly pacote data for sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg== not present. Using manifest.
7421 verbose stack Error: write after end
7421 verbose stack     at writeAfterEnd (_stream_writable.js:236:12)
7421 verbose stack     at PassThrough.Writable.write (_stream_writable.js:287:5)
7421 verbose stack     at PassThrough.Writable.end (_stream_writable.js:553:10)
7421 verbose stack     at ReadEntry.entry.on (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
7421 verbose stack     at emitOne (events.js:121:20)
7421 verbose stack     at ReadEntry.emit (events.js:211:7)
7421 verbose stack     at ReadEntry.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
7421 verbose stack     at ReadEntry.[maybeEmitEnd] (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
7421 verbose stack     at ReadEntry.end (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
7421 verbose stack     at Unpack.[consumeBody] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
7421 verbose stack     at Unpack.[consumeChunkSub] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
7421 verbose stack     at Unpack.[consumeChunk] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:360:30)
7421 verbose stack     at Unzip.(anonymous function).on.chunk (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
7421 verbose stack     at emitOne (events.js:116:13)
7421 verbose stack     at Unzip.emit (events.js:211:7)
7421 verbose stack     at Unzip.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
7422 verbose cwd /app
7423 verbose Linux 4.9.60-linuxkit-aufs
7424 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
7425 verbose node v8.9.4
7426 verbose npm  v5.7.1
7427 error write after end
7428 verbose exit [ 1, true ]

v9.7.1

7410 silly pacote data for sha512-zHo8v+otD1J10j/tC+VNoGK9keCuByhKovAvdn74dmxJl9+mWHnx6EMsDN4lgRoMI/eYo2nchAxniIbUPb5onw== not present. Using manifest.
7411 verbose stack Error [ERR_STREAM_WRITE_AFTER_END]: write after end
7411 verbose stack     at writeAfterEnd (_stream_writable.js:237:12)
7411 verbose stack     at PassThrough.Writable.write (_stream_writable.js:287:5)
7411 verbose stack     at PassThrough.Writable.end (_stream_writable.js:572:10)
7411 verbose stack     at ReadEntry.entry.on (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
7411 verbose stack     at ReadEntry.emit (events.js:132:15)
7411 verbose stack     at ReadEntry.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
7411 verbose stack     at ReadEntry.[maybeEmitEnd] (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
7411 verbose stack     at ReadEntry.end (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
7411 verbose stack     at Unpack.[consumeBody] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
7411 verbose stack     at Unpack.[consumeChunkSub] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
7411 verbose stack     at Unpack.[consumeChunk] (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:360:30)
7411 verbose stack     at Unzip.(anonymous function).on.chunk (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
7411 verbose stack     at Unzip.emit (events.js:127:13)
7411 verbose stack     at Unzip.emit (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
7411 verbose stack     at Unzip.write (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:90:17)
7411 verbose stack     at Unzip.write (/usr/local/lib/node_modules/npm/node_modules/tar/node_modules/minizlib/index.js:284:29)
7412 verbose cwd /app
7413 verbose Linux 4.9.60-linuxkit-aufs
7414 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
7415 verbose node v9.6.1
7416 verbose npm  v5.7.1
7417 error code ERR_STREAM_WRITE_AFTER_END
7418 error write after end
7419 verbose exit [ 1, true ]

How can the CLI team reproduce the problem?

Dockerfile

ARG NODE=9.7.1
ARG NPM=5.7.1
FROM node:$NODE
#FROM node:$NODE_VERSION-alpine
#FROM mhart/alpine-node:$NODE_VERSION
WORKDIR /app
RUN echo '{"dependencies":{"react": "^16", "webpack":"^4", "nyc": "^11", "mocha":"^5"}}' > package.json
RUN npm install -g npm@$NPM 
RUN npm install
docker build --build-arg NODE=8.9.4 --build-arg NPM=5.7.1 .
docker build --build-arg NODE=8.9.4 --build-arg NPM=5.7.0 .
docker build --build-arg NODE=9.7.1 --build-arg NPM=5.7.1 .
docker build --build-arg NODE=9.7.1 --build-arg NPM=5.7.0 .

The same error occurs in the node alpine and mhart/alpine-node images

supporting information:

  • See repro for versions
  • Docker for Mac 17.12.0-ce, OSX 10.11
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).
@liqueurdetoile

This comment has been minimized.

liqueurdetoile commented Mar 7, 2018

Hi,

Same issue when request update for this package : https://github.com/liqueurdetoile/DotObjectArray. It hurts on acorn deflate.

Error log :

2124 http fetch GET 200 https://registry.npmjs.org/acorn/-/acorn-5.5.1.tgz 777ms
2125 silly pacote acorn@^5.5.0 extracted in 789ms
2126 verbose stack Error: write after end
2126 verbose stack     at writeAfterEnd (_stream_writable.js:236:12)
2126 verbose stack     at PassThrough.Writable.write (_stream_writable.js:287:5)
2126 verbose stack     at PassThrough.Writable.end (_stream_writable.js:553:10)
2126 verbose stack     at ReadEntry.entry.on (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\extract-stream.js:19:41)
2126 verbose stack     at emitOne (events.js:121:20)
2126 verbose stack     at ReadEntry.emit (events.js:211:7)
2126 verbose stack     at ReadEntry.emit (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\node_modules\minipass\index.js:287:25)
2126 verbose stack     at ReadEntry.[maybeEmitEnd] (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\node_modules\minipass\index.js:240:12)
2126 verbose stack     at ReadEntry.end (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\node_modules\minipass\index.js:153:27)
2126 verbose stack     at Unpack.[consumeBody] (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:210:13)
2126 verbose stack     at Unpack.[consumeChunkSub] (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:391:40)
2126 verbose stack     at Unpack.[consumeChunk] (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:360:30)
2126 verbose stack     at Unzip.(anonymous function).on.chunk (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\lib\parse.js:291:59)
2126 verbose stack     at emitOne (events.js:116:13)
2126 verbose stack     at Unzip.emit (events.js:211:7)
2126 verbose stack     at Unzip.emit (C:\Users\Bureau\AppData\Roaming\npm\node_modules\npm\node_modules\tar\node_modules\minipass\index.js:287:25)
2127 verbose cwd F:\Projets\ObjectArray
2128 verbose Windows_NT 10.0.16299
2129 verbose argv "E:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Users\\Bureau\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "update"
2130 verbose node v8.9.4
2131 verbose npm  v5.7.1
2132 error write after end
2133 verbose exit [ 1, true ]

Downgrade NPM to 5.6.0 and it updates like a charm

@deployable deployable changed the title from npm install fails with "Error: write after end" or "ERR_STREAM_WRITE_AFTER_END" to npm install fails with "Error: write after end" or "ERR_STREAM_WRITE_AFTER_END" on 5.7.x Mar 7, 2018

@pradsdev

This comment has been minimized.

pradsdev commented Mar 9, 2018

Hi,
Had the same issue when i updated npm to 5.7.1.

Fix:
** Upgrade node to 8.10.x
This actually downgrades your npm to 5.6.0

** Then update npm using $ npm install npm -g
This will update npm to 5.7.1

Now npm install will work smoothly.

@Bene-Graham

This comment has been minimized.

Bene-Graham commented Mar 9, 2018

I tried what @pradsdev did but it still did not work for me.

I am running OSX High Sierra.

NPM 5.6.0 work fine.

jfcorsini added a commit to jfcorsini/habitica that referenced this issue Mar 11, 2018

Fix npm version on Dockerfile to 5.6.0
npm@5.7.1 is having some issue during extraction of large projects (see npm/npm#19989). So while this is not fixed, new contributors were not able to start a new local project, because the containers were updating npm to the newest version. In order to fix this issue I fixed the version to 5.6.0, which is more stable and it works on Habitica project.
@jeremy-j-ackso

This comment has been minimized.

jeremy-j-ackso commented Mar 11, 2018

Can confirm same issue on node v8.10.0 and npm v5.7.1. Was trying to install mocha and expect.js, but got the below error on pacote:

npm debug log:

396 http fetch GET 200 https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz 84ms
397 silly pacote browser-stdout@1.3.1 extracted in 124ms
398 verbose stack Error: write after end
398 verbose stack     at writeAfterEnd (_stream_writable.js:236:12)
398 verbose stack     at PassThrough.Writable.write (_stream_writable.js:287:5)
398 verbose stack     at PassThrough.Writable.end (_stream_writable.js:563:10)
398 verbose stack     at ReadEntry.entry.on (/usr/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
398 verbose stack     at emitOne (events.js:121:20)
398 verbose stack     at ReadEntry.emit (events.js:211:7)
398 verbose stack     at ReadEntry.emit (/usr/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
398 verbose stack     at ReadEntry.[maybeEmitEnd] (/usr/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
398 verbose stack     at ReadEntry.end (/usr/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
398 verbose stack     at Unpack.[consumeBody] (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
398 verbose stack     at Unpack.[consumeChunkSub] (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
398 verbose stack     at Unpack.[consumeChunk] (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
398 verbose stack     at Unzip.(anonymous function).on.chunk (/usr/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
398 verbose stack     at emitOne (events.js:116:13)
398 verbose stack     at Unzip.emit (events.js:211:7)
398 verbose stack     at Unzip.emit (/usr/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
399 verbose cwd /home/jeremy/Projects/experimenting-with-cicd
400 verbose Linux 4.9.0-6-amd64
401 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "--save-dev" "mocha" "expect.js"
402 verbose node v8.10.0
403 verbose npm  v5.7.1
404 error write after end
405 verbose exit [ 1, true ]
@jeremy-j-ackso

This comment has been minimized.

jeremy-j-ackso commented Mar 11, 2018

For anyone else looking at this, you should temporarily downgrade to npm v5.6.0 or lower until this is resolved.

npm i -g npm@5.6.0

@oshliaer

This comment has been minimized.

oshliaer commented Mar 12, 2018

I confirm the problem in node v9.8.0 (npm v5.7.1).
I have the same log as @jeremy-j-ackso
npm@5.6.0 works fine.

@tinoweb

This comment has been minimized.

tinoweb commented Mar 12, 2018

npm i -g npm@5.6.0 ===> solved my problem

@franciscohanna92

This comment has been minimized.

franciscohanna92 commented Mar 13, 2018

The solution by @jeremy-j-ackso solved my problem

@oshliaer

This comment has been minimized.

oshliaer commented Mar 13, 2018

It's not a solution. It seems we have a trouble. We have a root it is not there.

@vortechs2000

This comment has been minimized.

vortechs2000 commented Mar 14, 2018

Seeing this in Docker when attempting to install grunt-cli:

I'm using nvm, installing the latest boron node (6.13.1), then immediately installing latest npm (5.7.1). After that, I try to install grunt-cli, and get this (but only some of the time - maybe 1 out of 10 runs):

Making sure grunt-cli is setup via current version of node
/root/.nvm/versions/node/v6.13.1/bin/grunt -> /root/.nvm/versions/node/v6.13.1/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli@1.2.0
added 16 packages from 7 contributors in 2.361s
Removing existing node_modules
Installing node_modules
npm ERR! write after end 
@jjcad

This comment has been minimized.

jjcad commented Mar 14, 2018

@vortechs2000 Yours may or may not be related. You'll have to compare the more explicit info you have in your npm debug log with what other people are seeing to confirm that yours is definitely related. You're looking for something related to pacote.

Anyhow, if you can't find your debug log, check out the above temporary fix of downgrading to npm v5.6.0 to see if that takes care of it for you for until we get a fixed npm.

@ppissanetzky

This comment has been minimized.

ppissanetzky commented Mar 15, 2018

I can also reproduce this issue and am looking forward to a fix.

@soufianefariss

This comment has been minimized.

soufianefariss commented Mar 18, 2018

Downgrading to v5.6.0 solved the issue for me.

Thank you.

@Ashish2097

This comment has been minimized.

Ashish2097 commented Mar 19, 2018

I confirm the problem in node v9.8.0 (npm v5.7.1).
I have the same log as mentioned above.
Downgrading to npm@5.6.0 works.

@stejo009

This comment has been minimized.

stejo009 commented Mar 21, 2018

npm -v
5.7.1
node -v
v9.8.0

sudo npm install -g @angular/cli

npm ERR! code ERR_STREAM_WRITE_AFTER_END
npm ERR! write after end
npm ERR! code ERR_STREAM_WRITE_AFTER_END
npm ERR! write after end

npm ERR! A complete log of this run can be found in:
npm ERR! /home/strideadmin/.npm/_logs/2018-03-21T04_59_38_556Z-debug.log

Help me to fix these errors

@oshliaer

This comment has been minimized.

oshliaer commented Mar 21, 2018

@stejo009 look at the #19989 (comment)

@NicolasBehra

This comment has been minimized.

NicolasBehra commented Mar 21, 2018

Like said @pradsdev, just upgrade your nodeJs to 8.10.0,
On ubuntu, you just have to follow these steps :

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo n 8.10.0

See also : https://doc.ubuntu-fr.org/nodejs
Hope it helps :)

@a1626

This comment has been minimized.

a1626 commented Mar 21, 2018

@NicolasBehra the problem is not node but npm 5.7 so only downgrading npm will do the trick.

npm i -g npm@5.6.0

will resolve the issue for now.

@NicolasBehra

This comment has been minimized.

NicolasBehra commented Mar 21, 2018

ok, thanks @a1626 :)

@jhnferraris

This comment has been minimized.

jhnferraris commented Mar 21, 2018

Downgrading npm to 5.6.0 also fixed my issue.

@deployable

This comment has been minimized.

Contributor

deployable commented Mar 22, 2018

@a1626 I think the word is "workaround" 😄

@luckyrat

This comment has been minimized.

luckyrat commented May 10, 2018

npm 6.0.1 resolves the issue for me. Previously tested as failing in 6.0.0.

This includes a dependency update to pacote@8.1.1 which is the package that was implicated in the debug logs.

Node 8.11.1

@quetzalsly

This comment has been minimized.

quetzalsly commented May 10, 2018

6.0.1 still broken here, same error.

@SaudQureshi1997

This comment has been minimized.

SaudQureshi1997 commented May 10, 2018

Ubuntu 16.04
NPM version 5.7.1 & 6.0
Installing vue.
didn't work with this.
However npm install -g npm@5.6
and problem solved.
Thanks.

@DavidKk

This comment has been minimized.

DavidKk commented May 11, 2018

ubuntu 16.04
NPM version 6.0.1
NodeJS version v10.0.0
same problem
change to version 5.6.0 solve this problem

@JeanPerriault

This comment has been minimized.

JeanPerriault commented May 11, 2018

On macOS High Sierra, with a fresh node install, following all recommendations.

  • node v8.11.1, installed with nvm 0.33.11
  • npm 6.0.1
npm WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
events.js:183░░░░░░⸩ ⠼ extract:globals: sill extract react-helmet@5.2.0
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:563:10)
    at ReadEntry.entry.on (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)
    at ReadEntry.[maybeEmitEnd] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:249:12)
    at ReadEntry.end (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:162:27)
    at Unpack.[consumeBody] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:360:30)
    at Unzip.(anonymous function).on.chunk (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)
events.js:183░░░░░░⸩ ⠸ extract:babylon: sill extract download@4.4.3
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:563:10)
    at ReadEntry.entry.on (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)
    at ReadEntry.[maybeEmitEnd] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:249:12)
    at ReadEntry.end (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:162:27)
    at Unpack.[consumeBody] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
    at Unzip.(anonymous function).on.chunk (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)

And then several other errors like this

And then several warn tar ENOENT xxx

And then npm ERR! cancel after 1 retries!

And then terminal frozen...

Restarting computer solved node modules installation issue, but I still have those remaining and disappointing errors (but once again the installation looks successful 👍):

pm WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
events.js:183░░░░░░⸩ ⠧ extract:uuid: sill extract got@6.7.1
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:563:10)
    at ReadEntry.entry.on (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)
    at ReadEntry.[maybeEmitEnd] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:249:12)
    at ReadEntry.end (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:162:27)
    at Unpack.[consumeBody] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:360:30)
    at Unzip.(anonymous function).on.chunk (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)
events.js:183░░░░░░⸩ ⠼ extract:stable: sill extract socket.io-adapter@1.1.1
      throw er; // Unhandled 'error' event
      ^

Error: write after end
    at writeAfterEnd (_stream_writable.js:236:12)
    at PassThrough.Writable.write (_stream_writable.js:287:5)
    at PassThrough.Writable.end (_stream_writable.js:563:10)
    at ReadEntry.entry.on (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
    at emitOne (events.js:121:20)
    at ReadEntry.emit (events.js:211:7)
    at ReadEntry.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)
    at ReadEntry.[maybeEmitEnd] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:249:12)
    at ReadEntry.end (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:162:27)
    at Unpack.[consumeBody] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
    at Unpack.[consumeChunkSub] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
    at Unpack.[consumeChunk] (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
    at Unzip.(anonymous function).on.chunk (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
    at emitOne (events.js:116:13)
    at Unzip.emit (events.js:211:7)
    at Unzip.emit (/Users/xx/.nvm/versions/node/v8.11.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:296:25)```
@alundiak

This comment has been minimized.

alundiak commented May 11, 2018

@xilin npm cache clean --force didn't help. I did it before, and I did it now. I also reinstalled NodeJS 10.1.0 from pkg file on MacOS, which reinstalls npm for me also.

BTW. These days I also have another issue

NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing

And I decided to I npm install npm@latest -g => 6.0.1 and run npm audit and fix suggestions and updated my modules to latest version with help of ncu, looks like issue NODE_MODULE_VERSION described in initial post disappear for me.

But, then I checked the project where I have ERR_STREAM_WRITE_AFTER_EN issue, it still exists.

Here is initial instalation logs:

 my-tunes git:(master) ✗ npm install


> node-expat@2.3.16 install /Users/alund/prj/my-tunes/node_modules/node-expat
> node-gyp rebuild

  CC(target) Release/obj.target/expat/deps/libexpat/lib/xmlparse.o
  CC(target) Release/obj.target/expat/deps/libexpat/lib/xmltok.o
  CC(target) Release/obj.target/expat/deps/libexpat/lib/xmlrole.o
  LIBTOOL-STATIC Release/libexpat.a
  CXX(target) Release/obj.target/node_expat/node-expat.o
  SOLINK_MODULE(target) Release/node_expat.node
npm WARN my_tunes@1.0.0 No repository field.

added 214 packages from 187 contributors in 9.636s
[!] 5 vulnerabilities found [513 packages audited]
    Severity: 5 Low
    Run `npm audit` for more detail

Here is full log:

my-tunes git:(master) ✗ ./setup.sh 
reading: /Users/alund/Music/iTunes/iTunes Music Library.xml (2677482 bytes)
events.js:167||||||||||||||||||||||||||||||||||||||] 100 %
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_WRITE_AFTER_END]: write after end
    at writeAfterEnd (_stream_writable.js:243:12)
    at CsvTransformStream.Writable.write (_stream_writable.js:292:5)
    at CsvTransformStream.write (/Users/alund/prj/my-tunes/node_modules/fast-csv/lib/formatter.js:167:38)
    at CsvTransformStream._flush (/Users/alund/prj/my-tunes/node_modules/fast-csv/lib/formatter.js:188:14)
    at CsvTransformStream.prefinish (_stream_transform.js:141:10)
    at CsvTransformStream.emit (events.js:182:13)
    at prefinish (_stream_writable.js:633:14)
    at finishMaybe (_stream_writable.js:641:5)
    at endWritable (_stream_writable.js:652:3)
    at CsvTransformStream.Writable.end (_stream_writable.js:592:5)
Emitted 'error' event at:
    at writeAfterEnd (_stream_writable.js:245:10)
    at CsvTransformStream.Writable.write (_stream_writable.js:292:5)
    [... lines matching original stack trace ...]
    at CsvTransformStream.Writable.end (_stream_writable.js:592:5)

Looks like, my use case related to fast-csv module.

Any new ideas? Should I try downgrade back again to npm 5.6.0 ?
PS. I still want to use Node 10.1.0. But if node 9.x + npm 5.6.x works ok, then I will just wait till issue fixed for node 10.x + npm 6.x.

@peacememories

This comment has been minimized.

peacememories commented May 11, 2018

For our development machines it seems upgrading to npm@6.0.1-next.0 seems to fix the issue. This is a relief, since downgrading to npm@5.6.0 is not a good option for us.

@quetzalsly

This comment has been minimized.

quetzalsly commented May 11, 2018

For me it was also solved by downgrading to npm@6.0.1-next.0

@alundiak

This comment has been minimized.

alundiak commented May 11, 2018

npm@6.0.1-next.0 didn't help for me, but I created an issue in itunes-data which describes the way how I solved an issue. Simply, old dependency version needs to be upgraded. Looks like old version of npm modules built/published/released to NPM registry not consistent with new node/npm setup.

@fr4ngus

This comment has been minimized.

fr4ngus commented May 11, 2018

For me, I just upgrade to the latest node (v10.1.0) and npm (6.0.1) versions and it works.

@ilhamsa1

This comment has been minimized.

ilhamsa1 commented May 14, 2018

i have problem when install vue-cli 3, but using npm i -g npm@5.6.0 ,solved me thanks

@hesamira

This comment has been minimized.

hesamira commented May 14, 2018

Hi,
I have encountered these errors.
Please guide me.
Thanks.
sami@sami:/apps$ cd node-v8.11.1/
sami@sami:/apps/node-v8.11.1$ npm install express
npm ERR! write after end

npm ERR! A complete log of this run can be found in:
npm ERR! /home/sami/.npm/_logs/2018-05-14T13_07_05_083Z-debug.log

I have tested these commands, but I have not succeed.
npm install
npm cache clean
sudo npm install -g npm
npm install

@jbcpollak

This comment has been minimized.

Contributor

jbcpollak commented May 15, 2018

This error appears to happen with node 8.8.1 and npm 6.0.0:

Error: write after end
   at writeAfterEnd (_stream_writable.js:236:12)
   at PassThrough.Writable.write (_stream_writable.js:287:5)
   at PassThrough.Writable.end (_stream_writable.js:553:10)
   at ReadEntry.entry.on (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/pacote/lib/extract-stream.js:19:41)
   at emitOne (events.js:120:20)
   at ReadEntry.emit (events.js:210:7)
   at ReadEntry.emit (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
   at ReadEntry.[maybeEmitEnd] (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:240:12)
   at ReadEntry.end (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:153:27)
   at Unpack.[consumeBody] (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:210:13)
   at Unpack.[consumeChunkSub] (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:391:40)
   at Unpack.[consumeChunk] (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:362:30)
   at Unzip.(anonymous function).on.chunk (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/lib/parse.js:291:59)
   at emitOne (events.js:115:13)
   at Unzip.emit (events.js:210:7)
   at Unzip.emit (/Users/me/.nodenv/versions/8.8.1/lib/node_modules/npm/node_modules/tar/node_modules/minipass/index.js:287:25)
events.js:182░░░░░░⸩ ⠧ extract:supports-color: sill extract @angular/platform-browser-dynamic@5.2.4
     throw er; // Unhandled 'error' event
     ^
@viorelsfetea

This comment has been minimized.

viorelsfetea commented May 16, 2018

I am seeing the error with node 10.1.0 and npm 6.0.0 and 6.0.1 on Windows

@mpro7

This comment has been minimized.

mpro7 commented May 16, 2018

Have got npm ERR! code ERR_STREAM_WRITE_AFTER_END with npm 6.0.1 and node 9.11.1, but updating node to latest (10.1.0) helped.

@jbcpollak

This comment has been minimized.

Contributor

jbcpollak commented May 16, 2018

This appears to be a bug in node-tar: npm/node-tar#180

@stsvilik

This comment has been minimized.

stsvilik commented May 18, 2018

I have a PR to fix this issue (fingers crossed) zkat/pacote#151. Tested with npm 6.0.1 and node 10.0.0

Correction: I was running node 8.1.4 not 10.0.0

To fix node 10.0.0 - this PR will do the trick npm/node-tar#182

@4garfield

This comment has been minimized.

4garfield commented May 19, 2018

@stsvilik Thanks, this is works for me.
I'm running node v10.0.0 and npm 6.0.1

@swos-

This comment has been minimized.

swos- commented May 19, 2018

Adding to the list here:
Tried installing bootstrap (npm install --save bootstrap), and received the error: npm ERR! code ERR_STREAM_WRITE_AFTER_END

Ubuntu 17.10
Node 9.6.1
npm 6.0.1

The above advice to use npm cache clean -f seemed to clear up the issue. After running that, I was able to successfully install bootstrap.

zkat added a commit that referenced this issue May 20, 2018

pacote@8.1.3
Fixes: #19989
@zkat

This comment has been minimized.

Member

zkat commented May 20, 2018

I've merged a new version of pacote that should fix this thanks to the minipass patch. It's in release-next and will likely be included with 6.1.0 when the final release goes out next week.

I've also pushed the patch to the npm canary, if anyone's willing to double-check that it actually fixed what it should. You can use it by doing $ npx npmc install ....

Please do not reply to this thread unless you're testing out the canary or a version of npm later than npm@6.0.1-next.0 (the current published prerelease). I'm also going to close this because we usually close issues when the relevant patch has been merged. Cheers!

@zkat zkat closed this May 20, 2018

@zkat

This comment has been minimized.

Member

zkat commented May 22, 2018

This is now fixed in release-next, which will become npm@6.1.0-next.1, and the patch is now available (and confirmed with someone with a reliable repro!) in the npmc canary. So it's definitely fixed for real now and will go into the next npm release when 6.1.0 becomes latest :)

@npm npm locked as resolved and limited conversation to collaborators May 22, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.