ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 208 forks source link

Error Cant find module 'node-gcm'. #251

Closed ghost closed 7 years ago

ghost commented 8 years ago

The module node-gcm is working properly on my local system but when I try to use it on digital ocean using pm2 it shows an error - Can't find module 'node-gcm'. I am not able to get what is the problem.

hypesystem commented 8 years ago

Are you sure you have installed the module on your server? (npm install node-gcm)

eladnava commented 8 years ago

@hypesystem Maybe we should be recommending to --save to package.json when installing: https://github.com/ToothlessGear/node-gcm#installation

$ npm install node-gcm --save
hypesystem commented 8 years ago

I am torn: this seems like it should be really common knowledge, and might not work (if the folder has not yet been npm inited) -- on the other hand it might help a few people. I'll let that be up to you @eladnava -- whatever you think is best, I trust :smile:

eladnava commented 8 years ago

Actually, it works! 😄

Maybe they fixed it in the newer npm versions, but using node v4.4.5, running the following works (it installs the module but creates no package.json, which is fine):

cd ~
mkdir test
cd test
npm install node-gcm --save

# no error thrown
# node_modules/node-gcm exists! =)
ghost commented 8 years ago

Thanks it worked when I did npm install on DO server. But why did I have to do it again even if it was specified in package.json ?

eladnava commented 8 years ago

@monera23 do you have a npm-shrinkwrap.json file in your root project directory?

ghost commented 8 years ago

No.

eladnava commented 8 years ago

@monera23 Maybe when you deployed your app to the DigitalOcean server, you didn't run npm install in your project dir?

ghost commented 8 years ago

But earlier to this it has been working properly.

hypesystem commented 8 years ago

@monera23 what does your deployment process look like? What do you do when you need to deploy a new version?

@eladnava Great!

eladnava commented 7 years ago

Closing due to lack of response. Please reopen if you still experience this issue.