Apple M1,Yarn fail with error: ../node_modules/node-pty: Command failed

yarn fail with error: …/node_modules/node-pty: Command failed.

system info:
Apple M1
Monterey 12.3.1
xcode-select version: 2395
node: 14.17.0

more error message:
error /Users/tt/projects/tmp/demo/theia/node_modules/node-pty: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments:
Directory: /Users/tt/projects/tmp/demo/theia/node_modules/node-pty
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@7.1.2
gyp info using node@14.17.0 | darwin | x64
gyp info find Python using Python version 3.10.4 found at “/Library/Frameworks/Python.framework/Versions/3.10/bin/python3”
gyp info spawn /Library/Frameworks/Python.framework/Versions/3.10/bin/python3
gyp info spawn args [
gyp info spawn args ‘/Users/tt/projects/tmp/demo/theia/node_modules/@npmcli/run-script/node_modules/node-gyp/gyp/gyp_main.py’,
gyp info spawn args ‘binding.gyp’,
gyp info spawn args ‘-f’,
gyp info spawn args ‘make’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘/Users/tt/projects/tmp/demo/theia/node_modules/node-pty/build/config.gypi’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘/Users/tt/projects/tmp/demo/theia/node_modules/@npmcli/run-script/node_modules/node-gyp/addon.gypi’,
gyp info spawn args ‘-I’,
gyp info spawn args ‘/Users/tt/Library/Caches/node-gyp/14.17.0/include/node/common.gypi’,
gyp info spawn args ‘-Dlibrary=shared_library’,
gyp info spawn args ‘-Dvisibility=default’,
gyp info spawn args ‘-Dnode_root_dir=/Users/tt/Library/Caches/node-gyp/14.17.0’,
gyp info spawn args ‘-Dnode_gyp_dir=/Users/tt/projects/tmp/demo/theia/node_modules/@npmcli/run-script/node_modules/node-gyp’,
gyp info spawn args ‘-Dnode_lib_file=/Users/tt/Library/Caches/node-gyp/14.17.0/<(target_arch)/node.lib’,
gyp info spawn args ‘-Dmodule_root_dir=/Users/tt/projects/tmp/demo/theia/node_modules/node-pty’,
gyp info spawn args ‘-Dnode_engine=v8’,
gyp info spawn args ‘–depth=.’,
gyp info spawn args ‘–no-parallel’,
gyp info spawn args ‘–generator-output’,
gyp info spawn args ‘build’,
gyp info spawn args ‘-Goutput_dir=.’
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ ‘BUILDTYPE=Release’, ‘-C’, ‘build’ ]
CXX(target) Release/obj.target/pty/src/unix/pty.o
…/src/unix/pty.cc:691:10: error: use of undeclared identifier ‘openpty’
return openpty(amaster, aslave, name, (termios *)termp, (winsize *)winp);
^
1 error generated.
make: *** [Release/obj.target/pty/src/unix/pty.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/tt/projects/tmp/demo/theia/node_modules/@npmcli/run-script/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:376:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command “/Users/tt/.nvm/versions/node/v14.17.0/bin/node” “/Users/tt/projects/tmp/demo/theia/node_modules/.bin/node-gyp” “rebuild”
gyp ERR! cwd /Users/tt/projects/tmp/demo/theia/node_modules/node-pty

@hyy thank you for the discussion, please note that node v16 is likely necessary for M1 devices, it is the earliest node version that supports M1. Please also be sure to satisfy all prerequisites.

If you still experience issues can you include additional details as to what your package.json (application) looks like? Are you building a custom application, or attempting to build the main repository?

Additional Info:

I’m attempting to build the main repository and satisfy all prerequisites, but failed.

node: 16.14.2
yarn: 1.22.18
git: 2.32.0
pyhton3

@hyy unfortunately I am not on an M1 device (MacBook Pro 2016), so I can’t really troubleshoot the issue with you, at least on my machine the build is fine. It might be worthwhile to search and look around for issues related to M1 (node-pty, node-gyp) that may help.

Perhaps others will know as well and can chime in, and I’ll comment if I can think of something as well.

Thank you :smiley: