node-x509 icon indicating copy to clipboard operation
node-x509 copied to clipboard

Failed at the [email protected] install script 'node-gyp rebuild'

Open ashergarland opened this issue 7 years ago • 16 comments

My machine settings: Windows 10 npm -v // 4.5.0 node -v // 6.10.0

'npm install x509' fail to complete with the error:

LINK : fatal error LNK1181: cannot open input file 'C:\OpenSSL-Win64\lib\libeay32.lib' [C:\git\test\node_modules\x509\b uild\x509.vcxproj]

Failed at the [email protected] install script 'node-gyp rebuild'.

ashergarland avatar Apr 14 '17 17:04 ashergarland

I am facing same issue. Any progress on this?

kalpeshshirodker avatar May 11 '17 07:05 kalpeshshirodker

Sorry guys. Just changed jobs not too long ago and haven't had much time to keep up with this.

As for this error, I can't really say since I don't have a Windows computer to test the compilation with. Do you have OpenSSL installed to C:\OpenSSL-Win64?

Southern avatar May 11 '17 22:05 Southern

Getting the same issue on Linux Docker

oreporan avatar Jun 07 '17 10:06 oreporan

That OpenSSL-Win64 path comes from the 28th line of the binding.,gyp. That sucks, and makes this (and everything depending on this) unusable on Windows.

Edit: ah, sorry about being snarky, now I see where that path is coming from. A notice in the Readme would be appreciated, though.

For anyone looking for a solution, see: https://stackoverflow.com/a/39270114/477453 That is, get OpenSSL for Windows, version 1.0.2, from http://slproweb.com/products/Win32OpenSSL.html , and install it in the directory the installer suggests. And that's it, it will compile correctly, woooo.

Botffy avatar Jun 27 '17 15:06 Botffy

Am getting the same on CentOS 7.3 [root@centos7 ~]# npm install -g x509

[email protected] install /usr/lib/node_modules/x509 node-gyp rebuild

gyp ERR! clean error gyp ERR! stack Error: EACCES: permission denied, rmdir 'build' gyp ERR! stack at Error (native) gyp ERR! System Linux 3.10.0-514.26.2.el7.x86_64 gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/lib/node_modules/x509 gyp ERR! node -v v6.11.1 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok 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! /root/.npm/_logs/2017-07-19T16_15_49_944Z-debug.log [root@centos7 ~]#

bertrandszoghy avatar Jul 19 '17 16:07 bertrandszoghy

@Botffy no problem (re: snark). Mind opening a PR to modify the README since you have a Windows machine and know the steps that you had to take to get it working?

@bertrandszoghy your problem is a permission issue on your CentOS system. Check the output that you sent and you can see gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'. You would need to file a node-gyp issue for that.

@oreporan you can't be having this same Windows issue on a Linux container. What is the actual issue that you're running into?

@kalpeshshirodker do you have OpenSSL installed to C:\OpenSSL-Win64?

Southern avatar Jul 21 '17 18:07 Southern

Thanks,

As per

https://stackoverflow.com/questions/45193218/npm-fails-installing-fabric-ca-client/45198100#45198100

I can workaround by installing the npm package dependent on x509 locally (as opposed to globally as root).

Which was enough for my needs.

Best regards.

On Fri, Jul 21, 2017 at 2:12 PM, Colton Baker [email protected] wrote:

@Botffy https://github.com/botffy no problem (re: snark). Mind opening a PR to modify the README since you have a Windows machine and know the steps that you had to take to get it working?

@bertrandszoghy https://github.com/bertrandszoghy your problem is a permission issue on your CentOS system. Check the output that you sent and you can see gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'. You would need to file a node-gyp issue for that.

@oreporan https://github.com/oreporan you can't be having this same Windows issue on a Linux container. What is the actual issue that you're running into?

@kalpeshshirodker https://github.com/kalpeshshirodker do you have OpenSSL installed to C:\OpenSSL-Win64?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Southern/node-x509/issues/49#issuecomment-317073822, or mute the thread https://github.com/notifications/unsubscribe-auth/Abc0t1Wx1RPvwLWfS-vX_Wie5SD-vIcrks5sQOoHgaJpZM4M97d- .

bertrandszoghy avatar Jul 21 '17 18:07 bertrandszoghy

@bertrandszoghy no problem. I would still file an issue with node-gyp. Seeing as how you were doing the install as root, there should be no reason for you to be denied removing a directory. Something is definitely off there.

Southern avatar Jul 21 '17 18:07 Southern

Hi,

I'm getting a similar error on Debian.
I have been using this package on Centos with an early version of node. It works great. I'm trying to upgrade my system and your latest packages don't work to install.

I've followed instructions use this: npm install -g node-gyp npm install

With the latest version of node for the package I was using [email protected] and [email protected] it doesn't work to install.

Can you please fix this build issue, or supply the configuration you are using to test your current x509 package, or supply work around instructions?

Thank you in advance.

Error:

[email protected] install /opt/nodetest/node_modules/x509 node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/8.2.1" gyp WARN EACCES attempting to reinstall using temporary dev dir "/opt/nodetest/node_modules/x509/.node-gyp" gyp ERR! build error gyp ERR! stack Error: not found: make gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12) gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16 gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5 gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21) gyp ERR! System Linux 4.9.0-3-amd64 gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /opt/vogamazonecho/node_modules/x509 gyp ERR! node -v v8.2.1 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok 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! /root/.npm/_logs/2017-08-14T16_02_53_853Z-debug.log

vognition avatar Aug 14 '17 16:08 vognition

@vognition "gyp ERR! stack Error: not found: make" Well, do you have make? It's in the build-essential package, iirc.

Botffy avatar Aug 14 '17 17:08 Botffy

@Botffy Thanks. This is a new vm server installation. A few hands are on it. I thought the machine had that stuff installed already, but I guess not.

vognition avatar Aug 14 '17 17:08 vognition

I'm getting a similar error trying to deploy an application with Elastic Beanstalk using x509 v0.3.2 with node v8.1.4 (npm v5.0.3):

Application deployment failed at 2017-09-25T16:04:21Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed.

+ /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install

> [email protected] install /tmp/deployment/application/node_modules/x509
> node-gyp rebuild

gyp ERR! clean error 
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Linux 4.9.43-17.38.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v8.1.4-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v8.1.4-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/x509
gyp ERR! node -v v8.1.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
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! /tmp/.npm/_logs/2017-09-25T16_04_21_152Z-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v8.1.4-linux-x64/bin/npm
Setting npm config jobs to 1
npm config jobs set to 1
Running npm with --production flag
Failed to run npm install. Snapshot logs for more details.
UTC 2017/09/25 16:04:21 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log 

Traceback (most recent call last):
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in <module>
main()
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main
node_version_manager.run_npm_install(options.app_path)
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install
self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir'))
File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install
raise e
subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.1.4-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1.

Works fine locally on OS X. I tried all the hack-arounds from this thread, but no luck.

Seems like a node-gyp issue, but any insights? Admittedly, I do not really know how node-gyp works or is supposed to work. I don't really want to mess around with EB's base AMI permissions 🤒

jasonblanchard avatar Sep 25 '17 20:09 jasonblanchard

@jasonblanchard The line gyp ERR! stack Error: EACCES: permission denied, rmdir 'build' is pretty clear: the npm stack does not have permission to delete the build directory. Probably a different user runs the npm install, not the one who owns your application directory. I don't know much about EB, but there's this issue which sounds kinda similar.

Botffy avatar Sep 26 '17 00:09 Botffy

@Botffy Yup, agreed. After digging pretty deep into the EB deploy script, it appears to be running npm install as root and then switching to a different user context to run the package scripts, which I think is actually default npm behavior when running as root. We've submitted a ticket to AWS with steps to reproduce and they've acknowledged that they can reproduce it and forwarded the issue to their EB team. I'll post back here if they tell us anything useful.

In the meantime, the deploy works if you use the npm unsafe-perm option, which I don't feel particularly comfortable with since it seems unsafe (hence the name, I assume).

I also found a similar sounding issue with the farmhash library and it looks like they solved it by shipping the package with pre-compiled binaries, so that could be an option for node-x509 if other people are hitting this pain point.

jasonblanchard avatar Oct 23 '17 13:10 jasonblanchard

Heard back from AWS support and it sounds like this is actually an NPM 5 regression. Here are some relevant issues:

  • https://github.com/npm/npm/issues/17906
  • https://github.com/npm/npm/issues/17346

For now, using the unsafe-perm option is the recommended work-around, but EB will release a new base AMI when there is a patch in for this NPM issue.

jasonblanchard avatar Oct 26 '17 14:10 jasonblanchard

I have found a solution to @ashergarland's original issue as I too have had this issue. For Windows installing OpenSSL Version 1.1.0k, the libs were renamed from the libeay32.lib to libcrypto.dll. So the simple solution to this is to make an symbolic link using mklink in Windows. Tested on Windows 10 with Node Version 10.13.0.

Start CMD as Administrator

cd /d C:\OpenSSL-Win64\lib
mklink libeay32.lib libcrypto.lib

Output should match symbolic link created for libcrypto32.lib <<===>> libcrypto.lib I have done that and was building with no further issues with x509.

You can find a thread related to the file rename on StackOverflow

nhalstead avatar Jul 23 '19 15:07 nhalstead