0

I keep getting this error when i try to deploy my node app to google cloud, i've searched everywhere for a solution. From what i've seen so far i think the issue is with my node_modules folder although i deleted from my working directory and tried to deploy again, still didn't work

 node server.js

Server is running
module.js:549
    throw err;
    ^

Error: Cannot find module 'Mongoose'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/app/routes/feeds/index.js:3:18)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/app/server.js:161:14)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! b-net@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the b-net@1.0.0 start 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/2018-04-15T01_55_30_253Z-debug.log
  • is node_modules not there at all? is mongoose in your package.json dependencies? – Dan Oswalt Apr 15 '18 at 02:14
  • yes it is, all my packages are in package.json, and for some reason , i had the same problem in heroku –  Apr 15 '18 at 02:21
  • just trying to get at the simplest answers... they are in dependencies, not devDependencies? – Dan Oswalt Apr 15 '18 at 02:24
  • I'm new to deployment so i don't think i know the difference, i thought gcloud was to read my package.json file and then install the dependencies for me –  Apr 15 '18 at 02:26
  • well in the package.json, it gives you the ability to differentiate between development packages and production packages, so devDependencies is stuff that you would only want to use while building the app, but not include when it is ready to go. mongoose would probably always be in a 'dependencies' section – Dan Oswalt Apr 15 '18 at 02:30
  • I used --save and its under dependencies –  Apr 15 '18 at 02:34
  • hmmm in your require(), is mongoose capitalized? i believe it's case sensitive, it should be lowercase. – Dan Oswalt Apr 15 '18 at 02:52
  • `const mongoose = require('mongoose');` –  Apr 15 '18 at 12:33
  • Do you think you can share the code you are trying to deploy? Also look at this question and approved answer: https://stackoverflow.com/questions/9023672/how-do-i-resolve-cannot-find-module-error-using-node-js – Victor M Perez May 08 '18 at 10:16

0 Answers0