Search code examples
npm-installpermission-deniedandroid-app-signingnode-pty

Cannot install node-pty-prebuilt - too many errors


I'm trying to run expo opt-in-google-play-signing but it throws an error after I paste the encryption key of:

fatal error: too many errors emitted, stopping now [-ferror-limit=]
11 warnings and 20 errors generated.

and

Run npm -g install node-pty-prebuilt to install node pty
Error: Package node-pty-prebuilt is required to use PEPK tool

Initially when I ran the suggested npm install I had a permission issue which was solved using sudo chown -R $USER /usr/local/lib/node_modules but then when I run the solution npm -g install node-pty-prebuilt it fails again on:

fatal error: too many errors emitted, stopping now [-ferror-limit=]
11 warnings and 20 errors 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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--build_v8_with_gn=false"
gyp ERR! cwd /usr/local/lib/node_modules/node-pty-prebuilt
gyp ERR! node -v v12.16.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node scripts/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.

If run with sudo I get:

prebuild-install WARN install EACCES: permission denied, access '/Users/uxdw/.npm'

Running the chown script doesn't seem to solve the above access this time, giving:

gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/Users/uxdw/Library/Caches/node-gyp/12.16.2"

This is being run as the admin account on a macbook on Mojave.


Solution

  • This can be solved by simply downgrading the active Node version. At the time of writing it worked fine with either v10.12.0 or v10.13.0.

    I used Node Version Manager (NVM) to hot-swap between versions.

    Install NVM:

    Brew install nvm
    source ~/.nvm/nvm.sh (relinks nvm until is set as default on Terminal launch)
    

    Install Node versions:

    nvm install node // install node
    nvm install 8.9  // install specific version
    nvm uninstall x.x // uninstall specific version
    

    swap to a specific version:

    nvm use x.x // use a specific version
    

    For further details: NVM