"Error: Cannot find module 'pkginfo'" - node js app deploying to heroku - node.js

I'm getting the following error when attempting to deploy my node.js app to Heroku for the first time:
Application loaded using the "production" environment configuration
2014-08-28T01:02:56.823904+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:338:15)
2014-08-28T01:02:56.823906+00:00 app[web.1]: at Function.Module._load (module.js:280:25)
2014-08-28T01:02:56.823900+00:00 app[web.1]: Error: Cannot find module 'pkginfo'
2014-08-28T01:02:56.817349+00:00 app[web.1]: ^
2014-08-28T01:02:56.823915+00:00 app[web.1]: at Object.Module._extensions..js (module.js:474:10)
2014-08-28T01:02:56.823908+00:00 app[web.1]: at Module.require (module.js:364:17)
2014-08-28T01:02:56.823910+00:00 app[web.1]: at require (module.js:380:17)
2014-08-28T01:02:56.823912+00:00 app[web.1]: at Object. (/app/node_modules/passport-google-oauth/node_modules/passport-oauth/node_modules/passport/lib/passport/index.js:440:1)
2014-08-28T01:02:56.823913+00:00 app[web.1]: at Module._compile (module.js:456:26)
2014-08-28T01:02:56.823918+00:00 app[web.1]: at Function.Module._load (module.js:312:12)
2014-08-28T01:02:56.814921+00:00 app[web.1]:
2014-08-28T01:02:56.838954+00:00 app[web.1]: error: Forever detected script exited with code: 8
2014-08-28T01:02:56.815953+00:00 app[web.1]: throw err;
2014-08-28T01:02:56.823920+00:00 app[web.1]: at Module.require (module.js:364:17)
2014-08-28T01:02:56.823917+00:00 app[web.1]: at Module.load (module.js:356:32)
2014-08-28T01:02:56.815545+00:00 app[web.1]: module.js:340
I've followed all of the steps from Heroku's website for deploying node, but have been stuck on fixing this above error. I can successfully do "foreman start" on my local computer. At first, after doing "foreman start", I got the same error "Cannot find module 'pkginfo', so i installed pkginfo on my local computer and then foreman start worked and i could launch my app on localhost:5000 without any problems. However, still stuck on fixing this error on Heroku's server. Any help?
Thanks!
Jason

What you need to do is install the package in your production environment
1.Go into your main app directory
cd appDirectory
2.Install the module
npm install pkginfo
3.Re-deploy

Related

Unable to install npm package from github from package.json on heroku

I am using a package from github which is to be install from package.json file. But when I deploy the app on heroku, It is not able to install the package.
In package.json, I tried using different methods as below,
"sqlike": "git+https://username:access-token#github.com/vijjuu/SQLike.git"
"sqlike": "https://github.com/vijju/SQLike#master"
"sqlike": "https://github.com/vijjuu/SQLike/tarball/master"
"sqlike": "vijjuu/SQLike"
Error: Cannot find module 'SQLike'
2019-06-14T18:26:48.223971+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
2019-06-14T18:26:48.223973+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:562:25)
2019-06-14T18:26:48.223975+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:690:17)
2019-06-14T18:26:48.223976+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-06-14T18:26:48.223977+00:00 app[web.1]: at Object. (/app/server.js:2:18)
2019-06-14T18:26:48.223979+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:776:30)
2019-06-14T18:26:48.223980+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2019-06-14T18:26:48.223982+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-06-14T18:26:48.223983+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-06-14T18:26:48.223985+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
1) Your exporting your sql like but not importing it anywhere.
2) You don't have a server like ( node ) to run it on Heroku.

Node.js error: Cannot find module './decimal128'

I have a simple REST API deployed in Heroku. It uses MongoDB as the document storage service for the endpoints. It fails to run properly ever since I ran npm install to add another module for a different set of features. It doesn't matter what I do at that point, until I replace the node_modules folder (locally) with an older version before the last time I ran npm install, and re-deploy.
2018-08-03T16:12:14.920647+00:00 heroku[web.1]: Starting process with command npm start
2018-08-03T16:12:18.405746+00:00 app[web.1]:
2018-08-03T16:12:18.405762+00:00 app[web.1]: > todolistapi#1.0.0 start /app
2018-08-03T16:12:18.405764+00:00 app[web.1]: > node server.js
2018-08-03T16:12:18.405766+00:00 app[web.1]:
2018-08-03T16:12:18.593093+00:00 app[web.1]: /app
2018-08-03T16:12:18.594629+00:00 app[web.1]: /app
2018-08-03T16:12:19.115500+00:00 app[web.1]: module.js:549
2018-08-03T16:12:19.115542+00:00 app[web.1]: throw err;
2018-08-03T16:12:19.115544+00:00 app[web.1]: ^
2018-08-03T16:12:19.115545+00:00 app[web.1]:
2018-08-03T16:12:19.115547+00:00 app[web.1]: Error: Cannot find module './decimal128'
2018-08-03T16:12:19.115550+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:547:15)
2018-08-03T16:12:19.115551+00:00 app[web.1]: at Function.Module._load (module.js:474:25)
2018-08-03T16:12:19.115553+00:00 app[web.1]: at Module.require (module.js:596:17)
2018-08-03T16:12:19.115554+00:00 app[web.1]: at require (internal/module.js:11:18)
2018-08-03T16:12:19.115556+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2018-08-03T16:12:19.115558+00:00 app[web.1]: at Module._compile (module.js:652:30)
2018-08-03T16:12:19.115559+00:00 app[web.1]: at Object.Module._extensions..js (module.js:663:10)
2018-08-03T16:12:19.115561+00:00 app[web.1]: at Module.load (module.js:565:32)
2018-08-03T16:12:19.115562+00:00 app[web.1]: at tryModuleLoad (module.js:505:12)
2018-08-03T16:12:19.115564+00:00 app[web.1]: at Function.Module._load (module.js:497:3)
I read at least 10 other articles, and tried downgrading, reinstalling MongoDB with no success.
Issue: my local node_modules folders was being included in my push to Heroku. Once removed, the application runs fine on Heroku:
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master

Error deploying Hackernews Vue 2.0 sample code to Heroku and Google cloud

I am new to JS/Node.js/Vue.js and trying to learn about it and deploy the Hackernews code at https://github.com/vuejs/vue-hackernews-2.0. I was successfully able to deploy it locally on Windows 10 and Ubuntu and it worked fine (node v8.1.2, npm 5.0.3). After that, I tried deploying it on Heroku (git push heroku master) and also Google Could AppEngine (gcloud app deploy app.yaml) and I got the error "Cannot find module ./dist/vue-ssr-server-bundle.json" with both. Details below:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
yarn start v0.27.5
$ cross-env NODE_ENV=production node server
module.js:487
throw err;
^
Error: Cannot find module './dist/vue-ssr-server-bundle.json'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/server.js:41:18)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
error Command failed with exit code 1.
While trying to debug this issue further, I changed the package.json (line 8) from:
"start": "cross-env NODE_ENV=production node server",
to:
"start": "cross-env NODE_ENV=development node server",
and that also works fine locally. But on Heroku and Google cloud deployment, I got the different error:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
yarn start v0.27.5
$ cross-env NODE_ENV=development node server
module.js:487
throw err;
^
Error: Cannot find module 'glob'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/app/build/webpack.client.config.js:1:76)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
error Command failed with exit code 1.
I checked that the 'glob' dependency is there in package.json. Is this an issue with the code or am I missing something in my environment to deploy this to the cloud? What are the options to resolve this issue?
Thanks

Heroku Cannot Find Module (Model File)

I am getting a model import error in my Node.js application when deploying to Heroku.
2016-02-10T20:40:04.712617+00:00 app[web.1]: > node ./bin/www
2016-02-10T20:40:04.712615+00:00 app[web.1]: > comic#0.0.0 start /app
2016-02-10T20:40:05.770633+00:00 app[web.1]: throw err;
2016-02-10T20:40:05.770629+00:00 app[web.1]: module.js:341
2016-02-10T20:40:05.770637+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:339:15)
2016-02-10T20:40:05.770636+00:00 app[web.1]: Error: Cannot find module '../models/Comic'
2016-02-10T20:40:05.770638+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-02-10T20:40:05.770634+00:00 app[web.1]: ^
2016-02-10T20:40:05.770640+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-02-10T20:40:05.770641+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
2016-02-10T20:40:05.770639+00:00 app[web.1]: at require (internal/module.js:16:19)
2016-02-10T20:40:05.770642+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-02-10T20:40:05.770637+00:00 app[web.1]: at Function.Module._load (module.js:290:25)
2016-02-10T20:40:05.770640+00:00 app[web.1]: at Object.<anonymous> (/app/routes/create.js:2:13)
2016-02-10T20:40:05.770643+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-02-10T20:40:05.770642+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-02-10T20:40:05.804819+00:00 app[web.1]:
I have tried doing heroku run bash and running require('./models/Comic') from node session in app and require('../models/Comic') from within a subdirectory of /app/routes/ to test that require works.
The only instances of the require for Comic are in the three routes within the routes folder. They all have the exact same var myVar = require('../models/Comic');.
I figured out that heroku:
a) Takes the info from Git. Even though I had made case changes in my local files and pushed to Git, the case wasn't changed. Then when the file was required on heroku which uses Linux, it could not find the file.
b) Only changing the name of the file from heroku run bash didn't seem to have any affect. I am assuming I wasn't doing some sort of deployment step or that I needed to do something extra (I tried heroku restart but no dice).
Hope this can help someone else.

not able to run sails.js app using forever / pm2 in amazon ec2 / digitalocean ubuntu

I have installed sails.js (v0.9.16) globally in amazon-ec2 / digitalocean ubuntu..
sudo npm -g install sails
created a test project..
sails new sailstest
then lifted the server.. it works fine..
cd sailstest
sails lift
i can see sails app homepage on
http://<domain>:1337/
But when i am trying run it using pm2 from app directory,
pm2 start app.js
i am getting following error..
Error: Cannot find module 'sails'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/var/www/authenticator/sailstest/app.js:2:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (/usr/lib/node_modules/pm2/node_modules/coffee-script/lib/coffee-script/r$
at Function.Module._load (module.js:305:12)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at /usr/lib/node_modules/pm2/lib/ProcessContainer.js:151:5
at WriteStream.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainer.js:104:9)
at WriteStream.EventEmitter.emit (events.js:107:17)
at WriteStream.<anonymous> (fs.js:1668:10)
at Object.oncomplete (fs.js:97:15)
I tried running using forever as well..
forever start app.js
getting below error..
module.js:333
throw err;
^
Error: Cannot find module 'sails'
at Function.Module._resolveFilename (module.js:331:15)
at Function.Module._load (module.js:273:25)
at Module.require (module.js:357:17)
at require (module.js:373:17)
at Object.<anonymous> (/var/www/authenticator/sailstest/app.js:2:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Function.Module.runMain (module.js:490:10)
error: Forever detected script exited with code: 1
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/broadway/node_modu$
throw arguments[1]; // Unhandled 'error' event
^
Error: Cannot stop process that is not running.
at /usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/moni$
at process._tickCallback (node.js:343:11)
Any idea what is wrong?
I have upgraded to latest version of sails.js.. Now its working fine with forever and pm2...
npm -g update sails
Now sailsjs version 0.10.0-rc7 works fine with forever & pm2..

Resources