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

macOS NodeJS installation problem #237

Closed
kevincittadini opened this issue Oct 3, 2017 · 17 comments
Closed

macOS NodeJS installation problem #237

kevincittadini opened this issue Oct 3, 2017 · 17 comments
Labels
infrastructure Automated building and packaging O-macOS 💻 Operating system: macOS W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages

Comments

@kevincittadini
Copy link

kevincittadini commented Oct 3, 2017

If I run the command make install in the just cloned Themis repo, i get this error

 make install
-n link 
soter_static                   [WARNINGS]
ar rcs build/libsoter.a build/obj/soter/soter_container.o build/obj/soter/soter_crc32.o build/obj/soter/soter_hmac.o build/obj/soter/soter_kdf.o build/obj/soter/soter_sign.o build/obj/soter/ed25519/fe_0.o build/obj/soter/ed25519/fe_1.o build/obj/soter/ed25519/fe_add.o build/obj/soter/ed25519/fe_cmov.o build/obj/soter/ed25519/fe_copy.o build/obj/soter/ed25519/fe_frombytes.o build/obj/soter/ed25519/fe_invert.o build/obj/soter/ed25519/fe_isnegative.o build/obj/soter/ed25519/fe_isnonzero.o build/obj/soter/ed25519/fe_mul.o build/obj/soter/ed25519/fe_neg.o build/obj/soter/ed25519/fe_pow22523.o build/obj/soter/ed25519/fe_sq.o build/obj/soter/ed25519/fe_sq2.o build/obj/soter/ed25519/fe_sub.o build/obj/soter/ed25519/fe_tobytes.o build/obj/soter/ed25519/ge_add.o build/obj/soter/ed25519/ge_cmp.o build/obj/soter/ed25519/ge_double_scalarmult.o build/obj/soter/ed25519/ge_frombytes.o build/obj/soter/ed25519/ge_frombytes_no_negate.o build/obj/soter/ed25519/ge_madd.o build/obj/soter/ed25519/ge_msub.o build/obj/soter/ed25519/ge_p1p1_to_p2.o build/obj/soter/ed25519/ge_p1p1_to_p3.o build/obj/soter/ed25519/ge_p2_0.o build/obj/soter/ed25519/ge_p2_dbl.o build/obj/soter/ed25519/ge_p2_to_p3.o build/obj/soter/ed25519/ge_p3_0.o build/obj/soter/ed25519/ge_p3_dbl.o build/obj/soter/ed25519/ge_p3_sub.o build/obj/soter/ed25519/ge_p3_to_cached.o build/obj/soter/ed25519/ge_p3_to_p2.o build/obj/soter/ed25519/ge_p3_tobytes.o build/obj/soter/ed25519/ge_precomp_0.o build/obj/soter/ed25519/ge_scalarmult.o build/obj/soter/ed25519/ge_scalarmult_base.o build/obj/soter/ed25519/ge_sub.o build/obj/soter/ed25519/ge_tobytes.o build/obj/soter/ed25519/gen_rand_32.o build/obj/soter/ed25519/keypair.o build/obj/soter/ed25519/open.o build/obj/soter/ed25519/sc_muladd.o build/obj/soter/ed25519/sc_reduce.o build/obj/soter/ed25519/sign.o build/obj/soter/openssl/soter.o build/obj/soter/openssl/soter_asym_cipher.o build/obj/soter/openssl/soter_asym_ka.o build/obj/soter/openssl/soter_ec_key.o build/obj/soter/openssl/soter_ecdsa_common.o build/obj/soter/openssl/soter_hash.o build/obj/soter/openssl/soter_rand.o build/obj/soter/openssl/soter_rsa_common.o build/obj/soter/openssl/soter_rsa_key.o build/obj/soter/openssl/soter_rsa_key_pair_gen.o build/obj/soter/openssl/soter_sign_ecdsa.o build/obj/soter/openssl/soter_sign_rsa.o build/obj/soter/openssl/soter_sym.o build/obj/soter/openssl/soter_verify_ecdsa.o build/obj/soter/openssl/soter_verify_rsa.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: build/libsoter.a(keypair.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: build/libsoter.a(open.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: build/libsoter.a(sign.o) has no symbols
-n link 
themis_static                  [OK]
-n link 
soter_shared                   [ERRORS]
cc -shared -o build/libsoter.dylib build/obj/soter/soter_container.o build/obj/soter/soter_crc32.o build/obj/soter/soter_hmac.o build/obj/soter/soter_kdf.o build/obj/soter/soter_sign.o build/obj/soter/ed25519/fe_0.o build/obj/soter/ed25519/fe_1.o build/obj/soter/ed25519/fe_add.o build/obj/soter/ed25519/fe_cmov.o build/obj/soter/ed25519/fe_copy.o build/obj/soter/ed25519/fe_frombytes.o build/obj/soter/ed25519/fe_invert.o build/obj/soter/ed25519/fe_isnegative.o build/obj/soter/ed25519/fe_isnonzero.o build/obj/soter/ed25519/fe_mul.o build/obj/soter/ed25519/fe_neg.o build/obj/soter/ed25519/fe_pow22523.o build/obj/soter/ed25519/fe_sq.o build/obj/soter/ed25519/fe_sq2.o build/obj/soter/ed25519/fe_sub.o build/obj/soter/ed25519/fe_tobytes.o build/obj/soter/ed25519/ge_add.o build/obj/soter/ed25519/ge_cmp.o build/obj/soter/ed25519/ge_double_scalarmult.o build/obj/soter/ed25519/ge_frombytes.o build/obj/soter/ed25519/ge_frombytes_no_negate.o build/obj/soter/ed25519/ge_madd.o build/obj/soter/ed25519/ge_msub.o build/obj/soter/ed25519/ge_p1p1_to_p2.o build/obj/soter/ed25519/ge_p1p1_to_p3.o build/obj/soter/ed25519/ge_p2_0.o build/obj/soter/ed25519/ge_p2_dbl.o build/obj/soter/ed25519/ge_p2_to_p3.o build/obj/soter/ed25519/ge_p3_0.o build/obj/soter/ed25519/ge_p3_dbl.o build/obj/soter/ed25519/ge_p3_sub.o build/obj/soter/ed25519/ge_p3_to_cached.o build/obj/soter/ed25519/ge_p3_to_p2.o build/obj/soter/ed25519/ge_p3_tobytes.o build/obj/soter/ed25519/ge_precomp_0.o build/obj/soter/ed25519/ge_scalarmult.o build/obj/soter/ed25519/ge_scalarmult_base.o build/obj/soter/ed25519/ge_sub.o build/obj/soter/ed25519/ge_tobytes.o build/obj/soter/ed25519/gen_rand_32.o build/obj/soter/ed25519/keypair.o build/obj/soter/ed25519/open.o build/obj/soter/ed25519/sc_muladd.o build/obj/soter/ed25519/sc_reduce.o build/obj/soter/ed25519/sign.o build/obj/soter/openssl/soter.o build/obj/soter/openssl/soter_asym_cipher.o build/obj/soter/openssl/soter_asym_ka.o build/obj/soter/openssl/soter_ec_key.o build/obj/soter/openssl/soter_ecdsa_common.o build/obj/soter/openssl/soter_hash.o build/obj/soter/openssl/soter_rand.o build/obj/soter/openssl/soter_rsa_common.o build/obj/soter/openssl/soter_rsa_key.o build/obj/soter/openssl/soter_rsa_key_pair_gen.o build/obj/soter/openssl/soter_sign_ecdsa.o build/obj/soter/openssl/soter_sign_rsa.o build/obj/soter/openssl/soter_sym.o build/obj/soter/openssl/soter_verify_ecdsa.o build/obj/soter/openssl/soter_verify_rsa.o -L/usr/local/lib -L/usr/lib -lcrypto 
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [soter_shared] Error 1

If then I try to install jsthemis this is the error given

> jsthemis@0.9.5 preinstall /path/to/node_modules/jsthemis
> node-gyp configure && node-gyp build

  CXX(target) Release/obj.target/jsthemis/addon.o
In file included from ../addon.cpp:20:
../secure_session.hpp:22:10: fatal error: 'themis/themis.h' file not found
#include <themis/themis.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/jsthemis/addon.o] Error 1
gyp 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:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build"
gyp ERR! cwd /path/to/node_modules/jsthemis
gyp ERR! node -v v8.6.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-gesture-handler@1.0.0-alpha.23 requires a peer of react@> 15.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jsthemis@0.9.5 preinstall: `node-gyp configure && node-gyp build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the jsthemis@0.9.5 preinstall 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!     ~/.npm/_logs/2017-10-03T14_13_55_058Z-debug.log

I've OpenSSL and LibreSSL installed via Homebrew.
I've tried to solve all brew doctor notices.

I'm on macOS Sierra 10.12.6

I also do believe that some needed libraries are under /usr/lib whilst perhaps they should be under /usr/local/lib ?
There's a missing /usr/include folder as well.

@kevincittadini kevincittadini changed the title macOS NodeJS install problem macOS NodeJS installation problem Oct 3, 2017
@vixentael vixentael added the O-macOS 💻 Operating system: macOS label Oct 3, 2017
@vixentael
Copy link
Contributor

I think it means that make script cannot find OpenSSL.

  1. Please, run
$ brew --prefix openssl

You should see smth like /usr/local/opt/openssl

  1. Also please run
$ which openssl

to make sure that MacOS knows the path to openssl.

  1. You can configure Make script with path to openssl directly, like this:
make install CRYPTO_ENGINE_PATH=openssl CRYPTO_ENGINE_INCLUDE_PATH=<path_to_openssl>/openssl/include CRYPTO_ENGINE_LIB_PATH=<path_to_openssl>/openssl/lib

These params define to use openssl directly. On my Mac command looks like this:

make install CRYPTO_ENGINE_PATH=openssl CRYPTO_ENGINE_INCLUDE_PATH=/usr/local/opt/openssl/include CRYPTO_ENGINE_LIB_PATH=/usr/local/opt/openssl/lib

but it might be different in your case

@kevincittadini
Copy link
Author

Yes, running the last command successfully installs Themis via Make.
Thanks a lot.

This said, the problem with npm install remains. Different error though.

1 warning generated.
  SOLINK_MODULE(target) Release/jsthemis.node
clang: error: no such file or directory: '/usr/lib/libthemis.a'
clang: error: no such file or directory: '/usr/lib/libsoter.a'
make: *** [Release/jsthemis.node] Error 1
gyp 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:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build"
gyp ERR! cwd /path/to/node_modules/jsthemis
gyp ERR! node -v v8.6.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN lottie-react-native@1.1.1 requires a peer of react@>=15.3.1 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-branch@2.0.0-beta.3 requires a peer of react@>=15.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-gesture-handler@1.0.0-alpha.23 requires a peer of react@> 15.0.0 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! jsthemis@0.9.5 preinstall: `node-gyp configure && node-gyp build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the jsthemis@0.9.5 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@vixentael
Copy link
Contributor

It's our fault, we strictly use /usr/lib/ path instead of /usr/local/lib preferred on MacOS.

We've pushed super-small fix #238, however, it takes time to re-build and re-distribute the lib.

@kevincittadini can you please check changes locally?

  1. Please clone latest repo (master branch, including last pull request).
  2. Open src/wrappers/themis/jsthemis/ folder
  3. Run
$ node-gyp configure && node-gyp build

3.5 Install nan if it's not found (npm install nan)

  1. Building result should be success

Please let me know if it helped, we will update npm package then.

Thank you!

@kevincittadini
Copy link
Author

Success. No errors given. Everything seems nice and ok.
So, will I have to wait till the package is updated right?

Thank you so much for your fast reply and solutions.

@vixentael
Copy link
Contributor

Consider this as quick hack :) You can use this workaround as quick solution, we will update package next days.
I'll let you know right after we publish update :)

@kevincittadini
Copy link
Author

kevincittadini commented Oct 4, 2017

So, I've copied the full directory jsthemis (after the $ node-gyp configure && node-gyp build) inside the node_modules directory of my project. Is this the right way?

This is my code
var themis = require('themis');

Node throws this error:

Unable to resolve module 'jsthemis'

I'm surely missing something :)

@Lagovas
Copy link
Collaborator

Lagovas commented Oct 4, 2017

var themis = require('jsthemis'); is correct and now you can try just npm install jsthemis inside your project directory (we published fixed jsthemis package to npmjs registry)

@kevincittadini
Copy link
Author

kevincittadini commented Oct 4, 2017

After running npm install jsthemis, the console is looping on this

jsthemis@0.9.6-1 preinstall /path/to/node_modules/jsthemis
npm install && node-gyp configure && node-gyp build

This 2 lines keeps echoing

@Lagovas
Copy link
Collaborator

Lagovas commented Oct 4, 2017

yeah, my fault, sorry
until we fix that, you can try your previous steps (with manual building with node-gyp) and import jsthemis package instead themis: var themis = require('jsthemis');

@kevincittadini
Copy link
Author

kevincittadini commented Oct 4, 2017

This is my folder structure now under /path/to/node_modules/jsthemis/
I'm using ReactNative now, and in my .js file, when I import the package with:
var themis = require('jsthemis');

The system goes
Unable to resolve module 'jsthemis' from File.js: Module does not exist in the module map or in these directories: /path/to/node_modules
Before you ask: Yes, I tried to rebuild everything and clear various caches. Still got "unable to resolve module 'jsthemis'".

@Lagovas
Copy link
Collaborator

Lagovas commented Oct 4, 2017

please try now npm install jsthemis or pull new changes from our repository (git pull) and install to your project with npm install /absolute/path/themis/src/wrappers/themis/jsthemis from sources

@kevincittadini
Copy link
Author

kevincittadini commented Oct 4, 2017

Ok, no installation problems. Thank you for that.

Still Unable to resolve module 'jsthemis' from File.js: Module does not exist in the module map or in these directories: /path/to/node_modules error remains.

@Lagovas
Copy link
Collaborator

Lagovas commented Oct 4, 2017

as I understand now you have next structure:

project_folder:
 - node_modules
 - - module1
 - - module2
 - - jsthemis
 - some.js
 - some2.js
  1. do you have jsthemis in node_modules?
  2. can you run node -e "require('jsthemis');" inside <project_folder>? Is it prints any errors or nothing?

@kevincittadini
Copy link
Author

No errors running that on console. No output at all in fact.
I'm using ReactNative. Also tried to wipe all caches.

@Lagovas
Copy link
Collaborator

Lagovas commented Oct 4, 2017

if no errors and empty output then nodejs can find jsthemis correctly and the problem somewhere else (facebook/react-native#14209 maybe this will help)

@kevincittadini
Copy link
Author

I can confirm that jsthemis works fine now as of version 0.9.6-3.
Of course outside of ReactNative. I tried it in a classic index.js file and works fine.

Thanks a lot for your support and your fast replies.

@vixentael
Copy link
Contributor

Thank you @kevincittadini for reaching out :) You helped to make Themis better :)

@vixentael vixentael added infrastructure Automated building and packaging jsthemis labels Dec 13, 2017
@ilammy ilammy added W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages and removed E-Node.js labels Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure Automated building and packaging O-macOS 💻 Operating system: macOS W-JsThemis 🍭 Wrapper: JsThemis for Node.js, JavaScript API, npm packages
Projects
None yet
Development

No branches or pull requests

4 participants