Saturday, 2 March 2019

Soltuion of : Error: `gyp` failed with exit code: 1

It's been a long time to write a blog on some tech issue. This is related to setup a NodeJS project I almost spend 2-3 hours to fix some f**king issue with `gyp`  while ruining npm install.


Error:

gyp: binding.gyp not found (cwd: /Users/anilyadav/Documents/ahok/base12) while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/anilyadav/.nvm/versions/node/v6.9.2/lib/node_modules/node-gyp/lib/configure.js:345:16)
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 Darwin 18.2.0
gyp ERR! command "/Users/anilyadav/.nvm/versions/node/v6.9.2/bin/node" "/Users/anilyadav/.nvm/versions/node/v6.9.2/bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/anilyadav/Documents/ahok/base12
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.8.0

gyp ERR! not ok 




gyp: No Xcode or CLT version detected!
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/anilyadav/.nvm/versions/node/v6.9.2/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:308:16)
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 Darwin 18.2.0
gyp ERR! command "/Users/anilyadav/.nvm/versions/node/v6.9.2/bin/node" "/Users/anilyadav/.nvm/versions/node/v6.9.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/anilyadav/Documents/ahok/base12/node_modules/bcrypt
gyp ERR! node -v v6.9.2
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok 
npm WARN b12prj@0.0.3 No repository field.
npm WARN b12prj@0.0.3 No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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! A complete log of this run can be found in:
npm ERR!     /Users/anilyadav/.npm/_logs/2019-03-03T06_59_17_870Z-debug.log

Anils-MacBook-Pro:base12 anilyadav$ node-gyp rebuild



So finally found that this is something related to bcrypt version so after runing the below command it's working fine.


Solution:

$ sudo npm install --save bcrypt-nodejs && sudo  npm uninstall --save bcrypt

Hope It will help to save your time 

Sorry for my bad english. ;)



Tuesday, 22 August 2017

Expire collection data on specified number of seconds using MongoDB - TTL (Time to live)


I was working on some interesting feature of MongoDB know as TTL (Time to live) after understanding and google about the feature. I found that it's a very easy and use full feature of MongoDB for those who don't want to keep the unnecessary data/collection/documents in there MongoDB collection/table, so more like TTL is act like a background Job which executed on specific number of second. It's working based on index's in MongoDB for deleting the record/collection.

For detail understanding please visit: official documentation.

In my case : I need this to be work after every month for every single record so I added date but it's not working and because once on any collection you create a TTL index then I will not update the TTL expiration date value. So it's a bad way to do this also I notice that the TTL field are not Date type so if you are using : expireAfterSeconds   then please try to use number which is Seconds.

db.log_events.createIndex( { "createdAt": 1 }, { expireAfterSeconds: 3600 } )
Javascript best book ever click :)

Thursday, 10 August 2017

Saturday, 19 November 2016

Nginx SSL setup for multiple ports

This blog is related to setup SSL cert over Nginx server if you have .cert & .key file then you are able to setup this SSL If you don't have any please create locally or purchase from SSL provides.

SSL give use a secure socket protection which help to keep our domain / website heathy.

Below is the simple steps .

1) Upload your .cert & .key file on your server like Amazon Ec2 / Digital Ocean using any tool or "scp" ubuntu command.

2) Install Nginx on your server.
 
  • sudo apt-get update
  • sudo apt-get install nginx

3) After successfully installation you need to create a ssl_certs Folder in /etc/nginx/
mkdir /etc/nginx/ssl_certs
please check once if the folder is already exist then don't need to create the folder again .

4) Put your .cert & .key file in /etc/nginx/ssl_certs folder

5) Edit: /etc/nginx/sites-available/default and add your domain as per my given configuration.

6) Restart you nginx server
  • sudo systemctl restart nginx # New version of Ubuntu 16.04
  • sudo service nginx restart # older version of Ubuntu 14.04




Wednesday, 14 September 2016

Piwik database using Ruby script in Rails Framework

Ruby script for connecting Piwik Database in rails


One of my client I have two different application/Framework 1.Piwik: Which is used as a Analytic framework for tracking all the activites of a web sites and you can store your analytic data in your server basic need for using piwik it's free and easy to integrate with any application and it is provide very good support if you are a paid customer but it's available free also .

So why we need to integrate that PIWIK database in Rails ! Actually we had a requirement to show Analytic dashboard of piwik for some of the Account holder so our Admin maually create the client app on Piwik and we populating that piwik token and other stuff via connecting the Piwik database .


Easy way to create dump of mongodb database Raw

Dump from MogoDB server :)



Installing node version in centos 7 ( Digital Ocean )

Below are the some command which is use-full if you Installing node version in centos 7


Salesforce CRM vs. Zoho: A Comparative Analysis

Introduction: Selecting the right customer relationship management (CRM) software is crucial for businesses seeking to streamline their sal...