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

Error when doing npm install #307

Closed
weixingsun opened this issue Jun 8, 2016 · 16 comments
Closed

Error when doing npm install #307

weixingsun opened this issue Jun 8, 2016 · 16 comments
Labels
bug report Something is not working properly

Comments

@weixingsun
Copy link

weixingsun commented Jun 8, 2016

Hi termux experts,

I am facing an installation issue when doing my experiments: npm i bufferutil --save
node-gyp 3.3.1 was installed successfully by npm install -g node-gyp

$uname -a
Linux localhost 3.4.0-g09a22c6 #1 SMP PREEMPT Wed Apr 20 00:06:25 UTC 2016 armv7l Android
app: termux , linux 3.4.0-g1680ab8 in android 6.0.1
gcc: 6.1.0
make: 4.2
node v6.2.1
npm v3.9.5
node-gyp v3.3.1

Command to reproduce:
npm i bufferutil --save

Is it lacking of kerberos lib: libkrb5-dev ?

npm.install.txt

@fornwall
Copy link
Member

The formatting got messed up here. Could you:

  1. Write the command(s) to reproduce the problem (be sure to run apt update && apt upgrade first, so that you are running with updated packages)?
  2. Paste the output of uname -a here?

@clausreinke
Copy link

clausreinke commented Jul 3, 2016

I ran into this when trying to npm install node-sass. You should try running your install with verbose options, to see the full command behind SOLINK. If you see both -shared -rdynamic and -pie in the linker flags, have a look at the commit discussion here.

Workaround (if this is the issue): find your ~/.node-gyp/<version>/include/node/common.gypi, remove -pie from ldflags for android builds (for a better approach, see discussion). That should allow addon linking to proceed again..

@weixingsun
Copy link
Author

@clausreinke Thank you for your solution, I am able to build bufferutil module on my Nexus 7 2013 Android 6 now. Have you commit your fix ? so that we don't need to change the flags manually.
Btw, I was caught a bad cold for recent days, sorry for my late response.

@clausreinke
Copy link

I've asked the original committer to test and apply a fix, as it is his code, and i've got no experience with node-gyp. I suggest to follow that commit discussion to see when this issue is fixed.

@Neo-Oli Neo-Oli added the bug report Something is not working properly label Jul 29, 2016
@fornwall
Copy link
Member

@clausreinke What is the best way forward here? Should we try using a patch in the node package in termux, and then trying to get it upstream?

@rafis
Copy link

rafis commented Sep 3, 2016

No, no. After I've created simple JavaScript script to test:

var sqlite = require('sqlite3');

And it throws an error:

module.js:568
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: dlopen failed: cannot locate symbol "uv_close" referenced by "/data/data/com.termux/files/home/project/node_modules/sqlite3/lib/binding/node-v48-android-arm64/node_sqlite3.node"...
    at Error (native)
    at Object.Module._extensions..node (module.js:568:18)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/data/data/com.termux/files/home/project/www/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)

@clausreinke
Copy link

@fornwall It is a pity that the original committer has gone quiet - the problem is in his commit. It would be simple enough to make a pull request based on my suggested fix, but (1) the nodejs repo has rules which includes testing requirements and (2) might include android-only patches on a best-effort basis, giving no guarantees that a patch might not make things worse for someone else.

I do not currently have a setup for building and testing nodejs itself (or can we do that in termux?-) for/on android and on a supported platform.

@fornwall
Copy link
Member

@clausreinke Does this look like the correct patch?

diff -u -r ../node-v6.5.0/common.gypi ./common.gypi
--- ../node-v6.5.0/common.gypi> 2016-08-26 11:27:16.000000000 -0400
+++ ./common.gypi>      2016-09-14 06:35:35.551380791 -0400
@@ -78,7 +78,12 @@
           }],
           ['OS == "android"', {
             'cflags': [ '-fPIE' ],
-            'ldflags': [ '-fPIE', '-pie' ]
+            'ldflags': [ '-fPIE' ],
+            'target_conditions': [
+              ['_type == "executable"', {
+              'ldflags': [ '-pie' ]
+              }]
+           ]
           }],
           ['node_shared=="true"', {
             'msvs_settings': {

We could add it to the nodejs package in Termux, and propose it for inclusion upstream later.

@clausreinke
Copy link

@fornwall Looks about right, but there used to be two occurrences (a normal and a debug configuration?).

I tried to guess the syntax from similar stuff elsewhere in the file, and tested it for building packages on termux (on android). If it also works for you building node for termux (android), that would be two good points in favour of this change. If there was a way to run node's testsuite on android, a pull-request should be pretty obvious, as that includes building packages, which is what this issue is all about..

@fornwall
Copy link
Member

@clausreinke I realized that patching common.gypi in the nodejs source folder before building, does not affect the file that ends up in ~/.node-gyp/6.5.0/include/node/common.gypi, right? Do you know where that file comes from?

@clausreinke
Copy link

@fornwall That connection happens when the patch enters the newest release. See this comment, or the gist it links to. Node-gyp fetches those files from https://nodejs.org/download/release/vX.Y.Z/node-vX.Y.Z-headers.tar.gz.

Until then, you need to patch both copies, it seems.

@fornwall
Copy link
Member

@rafis Note that the process.dlopen issue was another problem (#462) that has now been fixed.

@rafis
Copy link

rafis commented Oct 19, 2016

@fornwall, thank you very much! Now everyhthing works. Only need to fix this issue (I had to mangle common.gypi manually, I havent tried 'target_conditions', I just remove '-pie' from 'ldflags').

@fornwall
Copy link
Member

fornwall commented Feb 7, 2017

I don't think this is an urgent issue anymore after switching to clang, as clang only emits a warning when -pie is added needlessly. So I'm closing this issue as the problem is upstream!

@ardyfeb
Copy link

ardyfeb commented Nov 14, 2018

@fornwall, thank you very much! Now everyhthing works. Only need to fix this issue (I had to mangle common.gypi manually, I havent tried 'target_conditions', I just remove '-pie' from 'ldflags').

I have remove -pie flag, but still error cannot linker
@fornwall

@bryanjhv
Copy link

bryanjhv commented Dec 6, 2018

@ardyfeb see #737.

@ghost ghost locked and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug report Something is not working properly
Projects
None yet
Development

No branches or pull requests

7 participants