yoonic / atlas

E-Commerce Backend API in Hapi.js and RethinkDB
MIT License
373 stars 104 forks source link

not able to install module bcrypt #1

Closed nash90 closed 8 years ago

nash90 commented 8 years ago

Hello,

Thanks for sharing this amazing project. I wanted to try and run this locally. But I encountered following issue. let me know if you have any idea about. I am new to node.

Nash:atlas abinash$ npm install

bcrypt@0.8.5 install /Users/abinash/ec_site/atlas/node_modules/bcrypt node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o ./Release/.deps/Release/obj.target/bcrypt_lib/src/blowfish.o.d.raw { dev: 16777220, mode: 33188, nlink: 1, uid: 501, gid: 20, rdev: 0, blksize: 4096, ino: 37968779, size: 87, blocks: 8, atime: 2016-09-01T04:31:13.000Z, mtime: 2016-09-01T04:31:13.000Z, ctime: 2016-09-01T04:31:13.000Z, birthtime: 2016-09-01T04:31:13.000Z } CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt.o ./Release/.deps/Release/obj.target/bcrypt_lib/src/bcrypt.o.d.raw { dev: 16777220, mode: 33188, nlink: 1, uid: 501, gid: 20, rdev: 0, blksize: 4096, ino: 37968782, size: 83, blocks: 8, atime: 2016-09-01T04:31:13.000Z, mtime: 2016-09-01T04:31:13.000Z, ctime: 2016-09-01T04:31:13.000Z, birthtime: 2016-09-01T04:31:13.000Z } CXX(target) Release/obj.target/bcrypt_lib/src/bcrypt_node.o In file included from ../src/bcrypt_node.cc:1: ../node_modules/nan/nan.h:592:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate' v8::Isolate::GCEpilogueCallback callback


../node_modules/nan/nan.h:598:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback) {
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:603:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:609:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback) {
      ~~~~~~~~~~~~~^
4 errors generated.
make: **\* [Release/obj.target/bcrypt_lib/src/bcrypt_node.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: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:204:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/abinash/ec_site/atlas/node_modules/bcrypt
gyp ERR! node -v v6.4.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm WARN atlas@1.0.0 No license field.
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v6.4.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.8.5 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/abinash/ec_site/atlas/npm-debug.log
andrecrt commented 8 years ago

Hi,

First of all thanks for your support! Looking forward to hear your thoughts after you get it working :)

I see from the log you posted above that you're running node v6.4.0 and npm v3.10.3. Can you try with node v4.x LTS? (I have it running in node.js v4.2.5 and npm v.3.5.3)

You can use something like https://github.com/creationix/nvm to switch between node.js versions.

Hope it helps! Looking forward to your feedback.

andrecrt commented 8 years ago

@nash90 any luck? :)

nash90 commented 8 years ago

@andreftavares Thank you very much for your response. I was able to run it after installing bcrypt manually. I also had to install sass manually npm install bcrypt@0.8.7 npm install node-sass@3.5.3

now i am trying to run atlas locally but getting some cross origin related issue. Again thanks for this wonderful project and sharing your knowledge.

andrecrt commented 8 years ago

@nash90 thanks for your answer! Will test those versions and perhaps update the requirements.

In regards to the "cross origin" issue, can you provide more details?

nash90 commented 8 years ago

@andreftavares The actual issue occurred when I was using atlas and nicistore simultaneously locally. nicistore failed to call apis in atlas. The javascript console log for nicistore app is attached. The error message is "XMLHttpRequest cannot load http://localhost:8000/api/v1/account. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404."

In my understanding as nicistore is hosted in localhost:3000 domain and api is in localhost:8000 domain, when nicistore calls the atlas api there is "No access-control-allow-origin header is present in the resource" issue.

I was wondering how you solve above issue. Regards,

screen shot 2016-09-05 at 11 56 14 pm

andrecrt commented 8 years ago

@nash90 did you try running your local Storefront (nicistore) first against the Live Nicistore API and then switching to your local install of Atlas?

Because, from what I can tell, your local install of the Storefront is looking for the API base URL in http://localhost:8000/api/v1. If you're running the default development settings of Atlas, it is exposing the API in base URL http://localhost:8000/v1 (notice the lack of "/api" prefix) <-- Change the settings in the Storefront for this value instead (link)

In the production site nicistore.com, since I'm running both apps (storefront and backend) under the same domain, I opted by mounting the API in the prefix "/api" of the domain, thus the base URL being "https://nicistore.com/api/v1" (link)

Hope this helps!

andrecrt commented 8 years ago

I've updated nicistore's readme to better explain this scenario (link) please tell me if you think it more clear :)

nash90 commented 8 years ago

@andreftavares After I changed the API base URL to http://localhost:8000/v1, it worked. Thank you so much. However, I didnt understand the reason of access-control-allow-origin error for earlier case.

I noticed that the response has following header this time when it worked which I think was not present in earlier case. access-control-allow-origin:http://localhost:3000

Does that mean the api is specially set to add above header in response for all requests. It would really help me to study this behaviour if could give me link to that portion of code.

nash90 commented 8 years ago

@andreftavares By the way, thanks for updating readme. Its very clear now.

andrecrt commented 8 years ago

@nash90 if you look closely, the issue is that the URL (http://localhost:8000/api/v1) simply does not exist and the API is returning a 404 Not Found :) I'm guessing that Hapi.js simply does not return CORS headers in the case of unexisting routes, thus the CORS message.

Indeed it can lead to misunderstandings... I got used to it, never did much research on the matter!

In Atlas, I configure Hapijs's CORS here https://github.com/yoonic/atlas/blob/master/src/server.js#L32-L35 and you can dig a little further in Hapij's documentation here http://hapijs.com/api

nash90 commented 8 years ago

@andreftavares Thanks for the info.