esbuild: Cannot install the package using node v16

I am running npm install --save-dev esbuild in a folder with only package.json file and getting this output:

npm ERR! code 1
npm ERR! path /home/tim/testesbuild/node_modules/esbuild
npm ERR! command failed
npm ERR! command sh -c node install.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tim/.npm/_logs/2021-10-26T10_37_48_991Z-debug.log

Log file ends with following:

170 info run esbuild@0.13.9 postinstall node_modules/esbuild node install.js
171 info run esbuild@0.13.9 postinstall { code: 1, signal: null }
172 timing reify:rollback:createSparse Completed in 5ms
173 timing reify:rollback:retireShallow Completed in 0ms
174 timing command:install Completed in 1718ms
175 verbose stack Error: command failed
175 verbose stack     at ChildProcess.<anonymous> (/home/tim/.npm-global/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
175 verbose stack     at ChildProcess.emit (node:events:390:28)
175 verbose stack     at maybeClose (node:internal/child_process:1064:16)
175 verbose stack     at Socket.<anonymous> (node:internal/child_process:450:11)
175 verbose stack     at Socket.emit (node:events:390:28)
175 verbose stack     at Pipe.<anonymous> (node:net:687:12)
176 verbose pkgid esbuild@0.13.9
177 verbose cwd /home/tim/testesbuild
178 verbose Linux 5.11.0-34-generic
179 verbose argv "/snap/node/5510/bin/node" "/home/tim/.npm-global/bin/npm" "install" "--save-dev" "esbuild"
180 verbose node v16.12.0
181 verbose npm  v8.1.0
182 error code 1
183 error path /home/tim/testesbuild/node_modules/esbuild
184 error command failed
185 error command sh -c node install.js
186 verbose exit 1

I am using Ubuntu 20.04

node --version                
v16.12.0
npm --version                 
8.1.0

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 27 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I’m having the same problem installing esbuild using node v16 on Ubuntu 21.04. Strangely I did not have this issue using WSL on Windows or on Mac.

Here’s the full log file for npm install --save-dev esbuild

Edit: ignoring the postinstall script (npm install --save-dev --ignore-scripts esbuild) got it installed and esbuild seems to be building my project without issue.

Unfortunately even that full log doesn’t provide enough information. And I’m still not able to reproduce this with these instructions on my Linux VM. Here’s what I tried:

$ mkdir test
$ cd test
$ echo {} > package.json

$ lsb_release -ds
Ubuntu 21.10

$ node --version
v16.13.1

$ npm --version
8.1.2

$ npm i esbuild@0.13.3
added 2 packages, and audited 3 packages in 2s
found 0 vulnerabilities

It seems to work fine. I’m going to close this issue because realistically there’s nothing I’m going to be able to do about it. If someone is experiencing it themselves then it would be great if they could debug it and post here about what the problem is. If the problem is identified, then the issue can be reopened.

To debug this what you’ll want to do is download the esbuild package from npm and extract it manually like this:

$ curl -O https://registry.npmjs.org/esbuild/-/esbuild-0.14.12.tgz
$ tar xf esbuild-0.14.12.tgz
$ rm esbuild-0.14.12.tgz
$ cd package

You can make whatever edits you want to the install script in the package directory (e.g. throwing an error that contains more information so it’ll show up in the log) and then try out the installation to see what happens:

$ cd package
$ npm pack # this will generate a new esbuild-0.14.12.tgz
$ cd ..
$ mkdir demo
$ cd demo
$ npm init -y
$ npm i ../package/esbuild-0.14.12.tgz

I am also facing same issue.

OS: Ubuntu 20.04 npm 8.2.0 node v16.13.1

npm install

npm ERR! code 1 npm ERR! path /home/sayful/Downloads/vitejs-vite-uun9ga/node_modules/esbuild npm ERR! command failed npm ERR! command sh -c node install.js

npm ERR! A complete log of this run can be found in: npm ERR! /home/sayful/.npm/_logs/2021-12-22T06_00_53_027Z-debug-0.log