dachev / node-cld

Language detection for Javascript (Node). Based on the CLD2 (Compact Language Detector) library from Google.
Apache License 2.0
316 stars 55 forks source link

Error: `make` failed with exit code: 2 #69

Closed naamapps closed 2 years ago

naamapps commented 2 years ago

Hey getting this error when trying to install on a nodejs project. Please advise, Thanks.

npm ERR! make: *** [Release/obj.target/cld/src/constants.o] Error 1
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 (/Users/user/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/user/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /Users/user/Documents/General Projects/sherfud-api/node_modules/cld
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
dachev commented 2 years ago

Hey @naamapps. This sounds like a macOS Monterey or M1- specific issue. Unfortunately I'm still on Intel with Big Sur so I can't reproduce. If you find the cause and fix it, I'll be happy to merge. Otherwise this will have to wait until I upgrade.

naamapps commented 2 years ago

I'm not on M1 Mac. Just on macos Monterey.. I'm not sure how to check what is the cause of this.. I guess I'll wait for your solution. Thanks

marlecce commented 2 years ago

Hi guys,

I've resolved the same issue by installing python2: unfortunately, python2 is not installed by default in the macOS Monterey version.

I hope it can help :)

o2themar commented 2 years ago

@marlecce Your solution does not work for someone using the latest alpine image that no longer supports python2. I have a docker image node:14-alpine that I am building and I install g++, make and python3 and even configure npm to set python to python3. However when the cld is building I am getting the same error as @naamapps .

Here is the error lines that are failing:

../src/cld.cc:5:12: error: 'terminate_handler' has not been declared in 'std'
    5 | using std::terminate_handler;
      |            ^~~~~~~~~~~~~~~~~
../src/cld.cc:6:12: error: 'unexpected_handler' has not been declared in 'std'
    6 | using std::unexpected_handler;
      |            ^~~~~~~~~~~~~~~~~~

Here is the same error that was shown before with my node and node-gyp versions:

 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:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Linux 5.10.104-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /transformer/node_modules/cld
gyp ERR! node -v v14.20.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 

All of the above is happening in a docker container.

o2themar commented 2 years ago

To fix the issue I had to update from cld 2.5.1 to version 2.8.1.

o2themar commented 2 years ago

The actual fix was in this commit: https://github.com/dachev/node-cld/commit/e0042ae65fb18f08b75b6fd19f6388561423e840 It seems at some point the obsolete code was removed in the latest alpine image of node:14-alpine and removing that line from the file might have done the trick. As mentioned cld 2.8.1 is able to compile without failing to build the cld.cc file.