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

Postinstall broken for pnpm 7+ #143

Closed
canadaduane opened this issue Apr 9, 2022 · 6 comments
Closed

Postinstall broken for pnpm 7+ #143

canadaduane opened this issue Apr 9, 2022 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@canadaduane
Copy link

canadaduane commented Apr 9, 2022

I've been messing around with this for a few hours. One of my dependencies (or sub-deps) includes es5-ext. When using pnpm (I'm using version 7.0.0-rc.2), the postinstall always fails with the following:

node_modules/.pnpm/es5-ext@0.10.60/node_modules/es5-ext: Running postinstall script...
 ELIFECYCLE  Command failed.

To replicate, install pnpm, then:

mkdir testproj
cd testproj
pnpm init
pnpm add es5-ext

OS: Linux (Pop!_OS 22.04)
Nationality: Canadian

Note: I do not have node in my PATH.

@medikoo
Copy link
Owner

medikoo commented Apr 9, 2022

@canadaduane Thanks for reporting it. Still I've just tested it and installation worked without issues:

Screenshot 2022-04-09 at 09 47 38

@medikoo medikoo added the question Further information is requested label Apr 9, 2022
@canadaduane
Copy link
Author

Do you have node in your PATH?

@matthijs-oosterhoff
Copy link

matthijs-oosterhoff commented Apr 11, 2022

I'm running into a similar issue. I have a a Docker image with a build environment for some legacy application. The Docker image installs gulp-cli, which has a dependency on es5-ext. Building that Docker image recently started failing and I pinpointed the issue to the _postinstall.js of es5-ext. Below you'll find a Dockerfile to reproduce the issue. This is a stripped down version of the one I use for my legacy Gulp application. It just installs es5-ext on top of Node 10 / NPM 7 from NVM.

FROM ubuntu:20.04

RUN apt-get update && apt-get install -y curl

ENV NVM_VERSION 0.39.1
ENV NODE_VERSION 10.22.1
ENV NPM_VERSION 7.24.0

RUN rm /bin/sh && ln -s /bin/bash /bin/sh
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v$NVM_VERSION/install.sh | bash \
    && chmod u+x /root/.nvm/nvm.sh \
    && . /root/.nvm/nvm.sh \
    && nvm install v$NODE_VERSION \
    && nvm use v$NODE_VERSION

ENV PATH="${PATH}:/root/.nvm/versions/node/v${NODE_VERSION}/bin"
RUN npm install -g npm@$NPM_VERSION

RUN npm install -g es5-ext

Output of docker build -t reproducer .:

(...)
Step 10/10 : RUN npm install -g es5-ext
 ---> Running in 3fd48e6dd463
npm notice 
npm notice New major version of npm available! 7.24.0 -> 8.6.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.6.0>
npm notice Run `npm install -g npm@8.6.0` to update!
npm notice 
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v10.22.1/lib/node_modules/es5-ext
npm ERR! command failed
npm ERR! command sh -c  node -e "try{require('./_postinstall')}catch(e){}"
npm ERR! sh: node: command not found

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-04-11T09_41_12_866Z-debug.log
The command '/bin/sh -c npm install -g es5-ext' returned a non-zero code: 127

The error as mentioned in the debug.log:

(...)
112 verbose stack Error: command failed
112 verbose stack     at ChildProcess.proc.on (/root/.nvm/versions/node/v10.22.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
112 verbose stack     at ChildProcess.emit (events.js:198:13)
112 verbose stack     at maybeClose (internal/child_process.js:982:16)
112 verbose stack     at Socket.stream.socket.on (internal/child_process.js:389:11)
112 verbose stack     at Socket.emit (events.js:198:13)
112 verbose stack     at Pipe._handle.close (net.js:607:12)
113 verbose pkgid es5-ext@0.10.60
114 verbose cwd /
115 verbose Linux 5.4.0-107-generic
116 verbose argv "/root/.nvm/versions/node/v10.22.1/bin/node" "/root/.nvm/versions/node/v10.22.1/bin/npm" "i" "-g" "es5-ext"
117 verbose node v10.22.1
118 verbose npm  v7.24.0
119 error code 127
120 error path /root/.nvm/versions/node/v10.22.1/lib/node_modules/es5-ext
121 error command failed
122 error command sh -c  node -e "try{require('./_postinstall')}catch(e){}"
123 error sh: node: command not found
124 verbose exit 127

As far as I am aware, node is on the PATH in the container. See line 16 of the Dockerfile, as wel as:

root@40d8b784b511:/# echo $PATH
/root/.nvm/versions/node/v10.22.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.nvm/versions/node/v10.22.1/bin
root@40d8b784b511:/# which node 
/root/.nvm/versions/node/v10.22.1/bin/node

I noticed 122 error command sh -c node -e "try{require('./_postinstall')}catch(e){}" in the debug log, which seems like an attempt to prevent the political script from breaking builds if anything misbehaves. I think another fallback may need to be added. I have nothing against these political statements in open source projects, but IMHO they should not break existing configurations.

@maddocnc
Copy link

Same error.

npm ERR! command sh -c  node -e "try{require('./_postinstall')}catch(e){}"
npm ERR! sh: 1: node: Permission denied

Also using nvm.

Please consider something like this #180

@jordanambra
Copy link

Also having this issue in a GitHub Action that installs the latest versions of serverless and serverless-python-requirements, which has a dependency of es5-ext.

@medikoo
Copy link
Owner

medikoo commented Apr 20, 2022

Sorry for the late response, I was on vacation last week.

I believe I've fixed that with v0.10.61 (just published). If you still see any issues please report
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants