Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gyp ERR! stack Error: make failed with exit code: 2 #1694

Closed
tasos31 opened this issue Mar 19, 2019 · 34 comments
Closed

gyp ERR! stack Error: make failed with exit code: 2 #1694

tasos31 opened this issue Mar 19, 2019 · 34 comments

Comments

@tasos31
Copy link

tasos31 commented Mar 19, 2019

I am trying to npm install my packages, and it seems a package named protagonist needs node-gyp

I have literally tried everything I found online (issues here included) and still cant solve this.

2 days I have spent searching around, changing node versions, reinstalling python and xcode tools etc, its driving me crazy.

Where should I focus? Could this be the problem? : clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later) But I have OS X 10.14...

I am literally at my wits end.

Any help really appreciated

  • Node Version:
    $ node -v
    v8.11.1
    (tried with a lot of other versions too: 6.X, 10.X, etc)

  • Platform:
    macOS Mojave 10.14.3
    Darwin USERNAME_Macbook-Pro.local 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64

  • Compiler:

Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • Module:
    form the error log, its
    [email protected]

  • Python Version (if it matters):
    $ python -V
    Python 2.7.16

  • Xcode verion (if it matters):
    $ /usr/bin/xcodebuild -version
    Xcode 10.1
    Build version 10B61

Verbose output (from npm or node-gyp):
[email protected] install /Users/user/project/project/node_modules/protagonist
node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
  CXX(target) Release/obj.target/libsnowcrash/snowcrash/src/CBlueprint.o
clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later)
make: *** [Release/obj.target/libsnowcrash/snowcrash/src/CBlueprint.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/user/.nvm/versions/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/Users/user/.nvm/versions/v8.11.1/bin/node" "/Users/user/.nvm/versions/v8.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/project/project/node_modules/protagonist
gyp ERR! node -v v8.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN [email protected] requires a peer of marked@^0.4.0 || ^0.5.0 || ^0.6.0 but none is installed. You must install peer dependencies yourself.
npm WARN project No repository field.
npm WARN project No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2019-03-18T23_01_15_767Z-debug.log

@richardlau
Copy link
Member

richardlau commented Mar 19, 2019

I am trying to npm install my packages, and it seems a package named protagonist needs node-gyp

I have literally tried everything I found online (issues here included) and still cant solve this.

2 days I have spent searching around, changing node versions, reinstalling python and xcode tools etc, its driving me crazy.

Where should I focus? Could this be the problem? : clang: error: invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later) But I have OS X 10.14...

Yes, that error describes the problem. [email protected] seems very old (https://github.com/apiaryio/protagonist/releases) and is setting 'MACOSX_DEPLOYMENT_TARGET': '10.5' in it's gyp scripts (https://github.com/apiaryio/protagonist/blob/7d25ee8622b4f981ecd05aeabd8e730858806aca/common.gypi#L128) which is less than the 10.7 needed to use libc++ on OS X.

I'd suggest updating to a later version of protagonist to see if the problem has been fixed, and if it hasn't raise an issue on their tracker: https://github.com/apiaryio/protagonist/issues

@richardlau
Copy link
Member

Looks like you need at least [email protected]: https://github.com/apiaryio/protagonist/pull/158/files

@tasos31
Copy link
Author

tasos31 commented Mar 22, 2019

@richardlau You are absolutely right!

Thank you very much for your time you took to reply and sorry.

@tasos31 tasos31 closed this as completed Mar 22, 2019
@henrik
Copy link

henrik commented Jun 7, 2019

In case someone else finds their way here for the same reason as I did: In my case it wasn't "protagonist" (it was "fsevents" and something else).

My fix was to downgrade node from 12 to 11; I was in a project created on Node 11 and then I tried running it on a new computer with Node 12. Ideally I'd "roll forward" and update dependencies until it works on Node 12, of course, but I didn't want to do that now.

@Volcaner
Copy link

image
image
image

that happened when i runned $ npm install (for react-ssr)

@shaikh-shahid
Copy link

Follow these steps to resolve the issue.

1: Make sure you have build-tools installed.
2: Update node-gyp
3: Delete package-lock.json and node modules folder and run npm install again.
4: Deleting ~/.node-gyp folder and run npm install again.

Source: https://codeforgeek.com/make-failed-with-exit-code-2/

@mikkz
Copy link

mikkz commented Jun 20, 2019

For those who are using AMI 2, I resolve it using

sudo yum groupinstall "Development Tools"

Since my errors were

make: Entering directory `/home/www/tieza-queue/notification/node_modules/fibers/build'
  CXX(target) Release/obj.target/fibers/src/fibers.o
make: g++: Command not found
make: *** [Release/obj.target/fibers/src/fibers.o] Error 127
make: Leaving directory `/home/www/tieza-queue/notification/node_modules/fibers/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/ec2-user/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.14.114-105.126.amzn2.x86_64
gyp ERR! command "/home/ec2-user/.nvm/versions/node/v10.15.3/bin/node" "/home/ec2-user/.nvm/versions/node/v10.15.3/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /home/www/tieza-queue/notification/node_modules/fibers
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
Alpine users please run: `sudo apk add python make g++`
sh: nodejs: command not found
npm WARN [email protected] requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] install: `node build.js || nodejs build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ec2-user/.npm/_logs/2019-06-20T07_19_19_837Z-debug.log

@nickpoulos
Copy link

I also experienced this issue, and it seemed my error also referenced fsevents. I believe this was also due to upgrading to Node 12. However @henrik I was able to resolve the issue without downgrading by following @codeforgeek's instructions for the most part.

  1. Make sure node build essentials are installed.
    sudo apt-get install build-essential

  2. Delete package-lock.json, /node_modules/ folder, and ~/.node-gyp/ folders.
    rm package-lock.json && rm -rf node_modules && rm -rf ~/.node-gyp

  3. Re-run npm install
    npm install

@jorwan
Copy link

jorwan commented Oct 8, 2019

if using yarn:

yarn upgrade

@MarkOates
Copy link

@jorwan thank you! That worked seamlessly solving the issues for me.

@shavo007
Copy link

yarn upgrade worked for me! i was using node 12 on mac 10.15

@lefrankleal
Copy link

if using yarn:

yarn upgrade

worked for me in MacOs Catalina

@clemlak
Copy link

clemlak commented Nov 16, 2019

I had the exact same issue after updating to Macos Catalina. After hours wasted looking for a solution, I fixed it by downgrading Node.js to 10.17.0. I hope this helps :)

@asifma
Copy link

asifma commented Nov 17, 2019

I downgraded to 10.16.0, and now its working.

@pushpendra-codemymobile

In case someone else finds their way here for the same reason as I did: In my case it wasn't "protagonist" (it was "fsevents" and something else).

My fix was to downgrade node from 12 to 11; I was in a project created on Node 11 and then I tried running it on a new computer with Node 12. Ideally I'd "roll forward" and update dependencies until it works on Node 12, of course, but I didn't want to do that now.

Just want to know why node-gyp not support node version 12 or latest.?

@richardlau
Copy link
Member

In case someone else finds their way here for the same reason as I did: In my case it wasn't "protagonist" (it was "fsevents" and something else).
My fix was to downgrade node from 12 to 11; I was in a project created on Node 11 and then I tried running it on a new computer with Node 12. Ideally I'd "roll forward" and update dependencies until it works on Node 12, of course, but I didn't want to do that now.

Just want to know why node-gyp not support node version 12 or latest.?

It does (assuming you are using an up to date version of node-gyp). Issues like these where downgrading Node.js "fixes" the issue are because the module being installed or one of its dependencies is not compatible with the later Node.js version.

@kozr
Copy link

kozr commented Jan 8, 2020

Downgraded to v10.18.0 via brew install node@10, It's now working.

@just-be-weird
Copy link

In my-case it was failing on Linux-mint 19.2, for some reasons on run-time gcc++ was not accessible.
So by installing the build-essentials error was resolved.
PS:

build-essential package is a reference for all the packages needed to compile a Debian packages. It generally includes the GCC/g++ compilers and libraries and some other utilities. Informational for list of build-essential packages can be found on build-essentials

@fengerzh
Copy link

This is really frustrating. I strongly hope node-gyp can work with node 13.

@GreenRidingHood
Copy link

I look-read-apply many gyp error solution, and only worked "in my case"
I downgraded node 13 to 11 ..

React Native Environment Info:
Binaries:
Node: 11.10.0 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
IDEs:
Android Studio: 3.0 AI-171.4443003
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: ^0.59.10 => 0.59.10
npmGlobalPackages:
react-native-cli: 2.0.1

@rvagg
Copy link
Member

rvagg commented Mar 10, 2020

Node 11 is no longer supported, please choose an LTS version instead - 10 or 12.

Compile errors like this are almost certainly a problem with the addon you're compiling, it's not something we can change here. You need to take it up with the addon author - they need to upgrade their code to work with a newer Node.js, or you need to upgrade the version of the addon you're installing because there's a good chance they've already released a new version.

@cihati
Copy link

cihati commented May 5, 2020

I downgraded to Node 10.x with Mac OS Catalina, and the issues were solved. I originally had 14.x and tried 12.x too, with no luck.

@fawnliu
Copy link

fawnliu commented Jul 10, 2020

if using yarn:

yarn upgrade

work !

@uyarn
Copy link

uyarn commented Aug 14, 2020

yarn global upgrade
cd ${yourReposDir}
rm package-lock.json
npm install

@Dae-Hwa
Copy link

Dae-Hwa commented Nov 25, 2020

I also experienced this issue, and it seemed my error also referenced fsevents. I believe this was also due to upgrading to Node 12. However @henrik I was able to resolve the issue without downgrading by following @codeforgeek's instructions for the most part.

  1. Make sure node build essentials are installed.
    sudo apt-get install build-essential
  2. Delete package-lock.json, /node_modules/ folder, and ~/.node-gyp/ folders.
    rm package-lock.json && rm -rf node_modules && rm -rf ~/.node-gyp
  3. Re-run npm install
    npm install

It works with windows WSL!

@cclauss
Copy link
Contributor

cclauss commented Nov 25, 2020

On non macOS platforms, the fsevents messages are warnings, not errors.
https://www.npmjs.com/package/fsevents#troubleshooting

@water-in-stone
Copy link

try npm install -g node-gyp

@yairopro
Copy link

yairopro commented Mar 1, 2021

@cclauss
Copy link
Contributor

cclauss commented Mar 1, 2021

@yairopro
Copy link

yairopro commented Mar 1, 2021

aaah thx

@byteab
Copy link

byteab commented Jun 10, 2021

node-gyp is the evil in the npm ecosystem

@Yogi-3
Copy link

Yogi-3 commented Jul 20, 2021

Got the same error, If you have installed node or yarn with brew, uninstall node and reinstall it,
for yarn, remove node it using brew uninstall node --ignore-dependencies
brew installs node when trying to install yarn.

@covard
Copy link

covard commented Sep 4, 2021

Downgraded to v10.18.0 via brew install node@10, It's now working.

Can confirm @kozr after downgrading node to 10 it works.

@Nazeeh21
Copy link

Had to downgrade to node version 14 due to this error 😩

@nodejs nodejs locked as resolved and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests