I'm currently facing an issue when attempting to utilize Visual Studio Code Dev Containers. Specifically, I encountered an npm error during my setup process. To provide some context, I opted to use Ubuntu as my development container environment. However, I ran into a problem while trying to install npm-pty, which led to the error message displayed below.
153 ms] Dev Containers 0.309.0 in VS Code 1.81.1 (6c3e3dba23e8fadc360aed75ce363ba185c49794).
[148 ms] Start: Resolving Remote
[247 ms] Start: Check Docker is running
[247 ms] Start: Run: docker version --format {{.Server.APIVersion}}
[350 ms] Server API version: 1.38
[352 ms] Start: Run: docker build -f /var/folders/m6/qgsyfz317p9ft38nb65s5zrh0000gn/T/vsch/bootstrap-image/0.309.0/bootstrap.Dockerfile -t vsc-volume-bootstrap /var/folders/m6/qgsyfz317p9ft38nb65s5zrh0000gn/T/vsch/bootstrap-image/0.309.0
Sending build context to Docker daemon 1.833MB
Step 1/5 : FROM mcr.microsoft.com/devcontainers/base:0-alpine-3.16
---> e348e1c8ff05
Step 2/5 : RUN echo "@old https://dl-cdn.alpinelinux.org/alpine/v3.15/main" >> /etc/apk/repositories
---> Using cache
---> b6a62e065413
Step 3/5 : RUN apk add --no-cache git-lfs nodejs python3 npm make g++ docker-cli docker-cli-buildx docker-cli-compose openssh-client-default@old ;
---> Using cache
---> 70ecbfbfb4f3
Step 4/5 : RUN cd && npm i node-pty
---> Running in 708f9e6c89ae
npm ERR! code 1
npm ERR! path /root/node_modules/node-pty
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/root/node_modules/node-pty/build'
npm ERR! make: Leaving directory '/root/node_modules/node-pty/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | x64
npm ERR! gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm ERR! gyp http GET https://nodejs.org/download/release/v16.20.1/node-v16.20.1-headers.tar.gz
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.20.1/node-v16.20.1-headers.tar.gz
npm ERR! gyp http GET https://nodejs.org/download/release/v16.20.1/SHASUMS256.txt
npm ERR! gyp http 200 https://nodejs.org/download/release/v16.20.1/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/node_modules/node-pty/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/16.20.1/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/16.20.1',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/16.20.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/root/node_modules/node-pty',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: printf: Operation not permitted
npm ERR! make: *** [pty.target.mk:111: Release/obj.target/pty/src/unix/pty.o] Error 127
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
npm ERR! gyp ERR! System Linux 4.9.93-linuxkit-aufs
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /root/node_modules/node-pty
npm ERR! gyp ERR! node -v v16.20.1
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-09-07T22_27_27_908Z-debug-0.log
The command '/bin/sh -c cd && npm i node-pty' returned a non-zero code: 1
[6375 ms] Command failed: docker build -f /var/folders/m6/qgsyfz317p9ft38nb65s5zrh0000gn/T/vsch/bootstrap-image/0.309.0/bootstrap.Dockerfile -t vsc-volume-bootstrap /var/folders/m6/qgsyfz317p9ft38nb65s5zrh0000gn/T/vsch/bootstrap-image/0.309.0
[6375 ms] Exit code 1
Given that I'm using the built-in script for Visual Studio Code Dev Containers, I'm uncertain whether there's anything I can do to resolve this issue. I'd greatly appreciate any insights or assistance in resolving this npm error and successfully configuring my development environment within Visual Studio Code Dev Containers. Thank you!
I had a similar issue, updating docker by downloading the latest version from their website fixed it for me.