microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.42k stars 233 forks source link

spawn node-gyp ENOENT #586

Closed linonetwo closed 1 year ago

linonetwo commented 1 year ago

Environment details

Issue description

% pnpm config set python /usr/local/Cellar/python@2/2.7.17_1/bin/python2
% pnpm i node-pty                                                       
Packages: +2
++
Progress: resolved 412, reused 371, downloaded 0, added 0, done
node_modules/.pnpm/node-pty@0.10.1/node_modules/node-pty: Running install script, failed in 206ms
.../node_modules/node-pty install$ node scripts/install.js
│ node:events:491
│       throw er; // Unhandled 'error' event
│       ^
│ Error: spawn node-gyp ENOENT
│     at ChildProcess._handle.onexit (node:internal/child_process:283:19)
│     at onErrorNT (node:internal/child_process:476:16)
│     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
│ Emitted 'error' event on ChildProcess instance at:
│     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
│     at onErrorNT (node:internal/child_process:476:16)
│     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
│   errno: -2,
│   code: 'ENOENT',
│   syscall: 'spawn node-gyp',
│   path: 'node-gyp',
│   spawnargs: [ 'rebuild' ]
│ }
│ Node.js v18.12.1
└─ Failed in 206ms at /Users/linonetwo/Desktop/repo/langchain-alpaca/node_modules/.pnpm/node-pty@0.10.1/node_modules/node-pty

I can see in the node_modules/node-pty/scripts/install.js there is

const gypProcess = spawn(os.platform() === 'win32' ? 'node-gyp.cmd' : 'node-gyp', gypArgs, {
  cwd: path.join(__dirname, '..'),
  stdio: 'inherit'
});

But there is no node-gyp in the folder

截屏2023-03-20 21 58 29

linonetwo commented 1 year ago

Solved by pnpm i -D node-gyp, which is unusual, normally I don't need to do this.

laptop-moment commented 1 year ago

Solved by pnpm i -D node-gyp, which is unusual, normally I don't need to do this.

Most modules don't have native code; this one does, hence node-gyp being necessary

node-pty should likely have node-gyp as a dependency to prevent this issue

deepak1556 commented 1 year ago

Please try with the latest version, the node-gyp dependency is not required since https://github.com/microsoft/node-pty/pull/567