Error while installing aerospike-node client on ubuntu 16.04

回眸只為那壹抹淺笑 提交于 2020-05-12 02:47:59

问题


I am trying to install aerospike-node client with npm on Ubuntu.

npm install aerospike

While installing I am getting ERROR like

SOLINK_MODULE(target) Release/obj.target/aerospike.node
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
aerospike.target.mk:186: recipe for target 'Release/obj.target/aerospike.node' failed
make: *** [Release/obj.target/aerospike.node] Error 1
rm binding_gyp_aerospike_client_c_target_run_scripts_aerospike_client_c_sh.intermediate
make: Leaving directory '/home/sys1095/NodeProjects/aerospike-test/node_modules/aerospike/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-21-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sys1095/NodeProjects/aerospike-test/node_modules/aerospike
gyp ERR! node -v v6.10.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 
npm WARN aerospike-test@1.0.0 No repository field.
npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "aerospike"
npm ERR! node v6.10.0
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

Environment :: node -v 6.10.0 ,node-gyp -v 3.4.0 ,npm -v 3.10.10.

I did check about this on aerospike github issues, But I didn't get anything(specific). I thought the main problem starts here

/usr/bin/ld: cannot find -lz

I didn't get what it was. Is problem with version of the node or anything regarding os(ubuntu) relating gcc compiler version.

Help me with this.


回答1:


I will post here what I did to get node.js working on Ubuntu 16.04 for my application from my scratch notes. Hopefully you can follow my steps, including my missteps!!!, and figure out where you missed out.

==== So here it goes ====

Install node.js Install and test node.js client on Ubuntu 16.04.1 LTS

https://nodejs.org/en/ Download and install latest recommended release for most users. node-v6.9.1-linux-x64.tar.xz

(Save the file to Downloads directory)

$ cd ~/Downloads/
$ tar xvf node-v6.9.1-linux-x64.tar.xz

⇒ node-v6.9.1-linux-x64 directory with all node.js components.

$ sudo mv node-v6.9.1-linux-x64 /usr/local/nodejs

Install Library Pre-requisistes

sudo apt-get install libssl0.9.8 libssl-dev liblua5.1-dev

(fails to find libssl0.9.8 - ubuntu 16.04 uses libssl1.0.0)

Let us do one at a time:

$sudo apt-get install liblua5.1-dev (<-- just need to do this) Reading package lists... Done Building dependency tree
Reading state information... Done Note, selecting 'liblua5.1-0-dev' instead of 'liblua5.1-dev' The following additional packages will be installed: autotools-dev libltdl-dev libtool libtool-bin Suggested packages: libtool-doc autoconf automaken gfortran | fortran95-compiler gcj-jdk The following NEW packages will be installed: autotools-dev libltdl-dev liblua5.1-0-dev libtool libtool-bin 0 upgraded, 5 newly installed, 0 to remove and 165 not upgraded. Need to get 594 kB of archives. After this operation, 3,180 kB of additional disk space will be used.

$sudo apt-get install libssl-dev (see below, already installed) Reading package lists... Done Building dependency tree
Reading state information... Done libssl-dev is already the newest version (1.0.2g-1ubuntu4.5). 0 upgraded, 0 newly installed, 0 to remove and 165 not upgraded.

$ sudo apt-get install libssl1.0.0 (see below, already installed) Reading package lists... Done Building dependency tree
Reading state information... Done libssl1.0.0 is already the newest version (1.0.2g-1ubuntu4.5). 0 upgraded, 0 newly installed, 0 to remove and 165 not upgraded.

Add the symlinks:

$ sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.so /usr/lib/liblua.so
$ sudo ln -s /usr/lib/x86_64-linux-gnu/liblua5.1.a /usr/lib/liblua.a
$ ls /usr/lib/liblua*

lrwxrwxrwx 1 root root 37 Nov 2 13:17 /usr/lib/liblua.a -> /usr/lib/x86_64-linux-gnu/liblua5.1.a lrwxrwxrwx 1 root root 38 Nov 2 13:17 /usr/lib/liblua.so -> /usr/lib/x86_64-linux-gnu/liblua5.1.so

Install npm

(If you don't have npm, you cannot install aerospike node.js client.)

$ npm install aerospike

The program 'npm' is currently not installed. You can install it by typing: sudo apt install npm

$ sudo apt install npm

Run Application

($cd your_location/your_application/Node) modify package.json.

is:

{
  "name": "xxx-app",
  "version": "0.0.1",
  "dependencies": {
    "aerospike": "^1.0.36",
    "inquirer": "^0.8.0"   <--- my app specific
  }
}

change: "aerospike": "^2.0.0",

Then, $npm install inquirer --save-dev (inquirer is a command line i/o library for my app.)

$npm install aerospike --save-dev

It should update package.json to something like this:

$ more package.json
{
  "name": "xxx-app",
  "version": "0.0.1",
  "dependencies": {
    "aerospike": "^2.0.0",
    "inquirer": "^0.8.0"
  },
  "devDependencies": {
    "aerospike": "^2.4.1",
    "inquirer": "^0.8.5"
  }
}

Running Node -- (my) app.js In the appropriate sub-directory:

$which nodejs
/usr/bin/nodejs
$nodejs app.js


来源:https://stackoverflow.com/questions/42554516/error-while-installing-aerospike-node-client-on-ubuntu-16-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!