ElementsProject / lightning-charge

A simple drop-in solution for accepting lightning payments
MIT License
554 stars 80 forks source link

Update Installation Docs for Ubuntu #49

Closed ccdle12 closed 5 years ago

ccdle12 commented 6 years ago

Hi,

I was setting up lightning-charge to integrate with the WordPress Plugin. I had some difficulties with installation in my environment so I thought this might useful to other devs. Please let me know if this would be better closed.

Environment

Installation

  1. Nodejs 7 and 10 were not compatible with lightning-charge, had to install nodejs8

    • $ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash

    • $ apt-get install nodejs

  2. Errors running npm install lightning-charge, had to include the following flags

    • $ npm install --unsafe-perm --verbose -g lightning-charge
  3. Sqlite3 dependency weren't found in the node_modules, had to run npm rebuild

    • $ cd /usr/lib/node_modules/lightning-charge
    • $ npm rebuild

After the above steps everything worked well following the steps in the README to run the server.

rbensberg commented 6 years ago

ACK

k3tan172 commented 5 years ago

Can this be mentioned on the main page please? It did my head in thinking there was a problem with my npm.

shesek commented 5 years ago
  1. Lightning Charge should be compatible with nodejs >= 7.6, can you share the errors you had with node 7 and 10?

  2. Using --unsafe-perm should definitely not be needed. This depends on how your environment is setup exactly, but you would usually either install global npm packages with sudo, or configure your npm to install packages to your home dir (which will make sudo unnecessary).

  3. I think this was because you switched nodejs versions in between, this should not be required normally.

@k3tan25 What is the issue that you ran into exactly?

k3tan172 commented 5 years ago

Note I haven't tried the instructions set out here, but currently this is error I'm facing. Have not switched nodejs versions.

root@seedbox:~# sudo npm install -g lightning-charge
/usr/bin/charged -> /usr/lib/node_modules/lightning-charge/bin/charged

> sqlite3@4.0.4 install /usr/lib/node_modules/lightning-charge/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for sqlite3@4.0.4 and node@10.15.1 (node-v64 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding' 
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/10.15.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/.node-gyp'
gyp ERR! System Linux 4.15.0-45-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v64-linux-x64" "--napi_version=3" "--node_abi_napi=napi"
gyp ERR! cwd /usr/lib/node_modules/lightning-charge/node_modules/sqlite3
gyp ERR! node -v v10.15.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v64-linux-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/lightning-charge/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 4.15.0-45-generic
node-pre-gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/lightning-charge/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/lib/node_modules/lightning-charge/node_modules/sqlite3
node-pre-gyp ERR! node -v v10.15.1
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/usr/lib/node_modules/lightning-charge/node_modules/sqlite3/lib/binding/node-v64-linux-x64 --napi_version=3 --node_abi_napi=napi' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/lightning-charge/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sqlite3@4.0.4 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sqlite3@4.0.4 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/2019-03-02T19_57_59_845Z-debug.log

Note to get this error I'm running sudo -i AND sudo infront of the command. I get permission denied errors when I run as normal user with sudo. Permission denied errors as just root as well. Any help would be appreciated.

k3tan172 commented 5 years ago

Disregard, I got it working with "configure your npm to install packages to your home dir" link you cited.

shesek commented 5 years ago

Disregard, I got it working with "configure your npm to install packages to your home dir" link you cited.

Great! I also added this suggestion to the readme in https://github.com/ElementsProject/lightning-charge/commit/f6cd79a7ec4a2790b9b09ae6623c782ed0220914

waxapi commented 5 years ago

I would highly recommend learning and using Docker with lightningcharge which would eliminate the risk of compatibility problems.