I am trying to host this https://github.com/idiidk/kahoot-tools on google cloud. It works when i test it in cloud shell but when i deploy it it crashes.
I see this error when i go to my app:
Error: Server Error The server encountered an error and could not
complete your request. Please try again in 30 seconds.
In google cloud i see this error:
Error: Cannot find module 'express' at
Function.Module._resolveFilename
(internal/modules/cjs/loader.js:581:15) at Function.Module._load
(internal/modules/cjs/loader.js:507:25) at Module.require
(internal/modules/cjs/loader.js:637:17) at require
(internal/modules/cjs/helpers.js:22:18) at Object.
(/srv/kahoot-tools.js:8:21) at Module._compile
(internal/modules/cjs/loader.js:689:30) at
Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32) at
tryModuleLoad (internal/modules/cjs/loader.js:538:12) at
Function.Module._load (internal/modules/cjs/loader.js:530:3)
express package is missing in "dependencies" of package.json. just add the following:
"express": "^4.16.3"
and also add this node for deploying to App Engine, otherwise dependencies won't get installed:
"scripts": {
"start": "node kahoot-tools.js"
}
Related
I have a simple node.js express application.
When I run npm run serve, I am getting below error.
In my node_modules folders I can see merge-descriptors folder, but when I try to start express server, looks like it is complaining about not able to find the component.
My path correctly has node_modules/.bin set.
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module 'merge-descriptors'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (/tmp/site/node_modules/express/lib/express.js:16:13)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
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
I made this app 1-2 years ago, and I was new to node so I didn't make a proper package.json file when it was created. for some reason, it's not running any more. here is the error when i try to run server.js.
elliott:nodejs_websocket_osc mrtunes$ node server.js
info - socket.io started
/Users/mrtunes/Documents/webmusic/nodejs_websocket_osc/node_modules/node-osc/node_modules/osc-min/node_modules/binpack/node_modules/bindings/bindings.js:83
throw e
^
Error: Module did not self-register.
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at bindings (/Users/mrtunes/Documents/webmusic/nodejs_websocket_osc/node_modules/node-osc/node_modules/osc-min/node_modules/binpack/node_modules/bindings/bindings.js:76:44)
at Object.<anonymous> (/Users/mrtunes/Documents/webmusic/nodejs_websocket_osc/node_modules/node-osc/node_modules/osc-min/node_modules/binpack/index.js:1:99)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
it looks like the bindings module is from the osc-min folder. i tried to go in there and run an npm install but no luck. i put everything on the github
I've stumbled upon some issues when deploying to AWS beanstalk.
At first I thought the problem is with my Node.js app, but then I've tried clean install.
I've created blank Node.js Express app with WebStorm. Created new Application at AWS Beanstalk running on nginx 1.6.2
Then I zip my app and deploy it through Beanstalk console.
Upload completes successfully, however when I run application i get 502 bad gateway.
I've tried to change the default port since Web Storm creates app running on port 3000, so I've changed it to 8081. But i still get the error. When looking up for error in logs I've got the following.
/var/log/nodejs/nodejs.log
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/app/current/app.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)module.js:340
throw err;
Error: Cannot find module '/var/app/current/routes/index'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/app/current/app.js:8:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
module.js:340
It's clear that the problem is because node fails to find modules because of the relative path so I changed all entries with relative paths to use absolute path. for Example
var app = require('../app');
I've changed to
var path = require('path');
var app = require(path.join(__dirname, '../app'));
Still I get the same error.
Also I get the following error in nginx log:
/var/log/nginx/error.log
-------------------------------------
2014/12/05 14:28:35 [error] 23444#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.25.31, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "nodesampleapp-env.elasticbeanstalk.com"
Any idea why this is happening?
Appreciate any help.
In my case, the node file name was wrong.
{
"name": "your application-name",
"version": "0.0.1",
"private": true,
"scripts":
{
"start": "node app_bot.js"
},
...
I have a simple node app that I am trying to host on cloudfoundry. I am using the node module srand.
When I visit the url, I get this error.
Error: Cannot find module './build/default/srand.node'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/var/vcap/data/dea/apps/UnfoundedAccusations-0-8f4d453d8731dd95a14f10aeddc17eae/app/node_modules/srand/index.js:4:20)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
Recently cloudfoundry made some changes for Node.js modules support. Have a look at here http://blog.cloudfoundry.com/2012/12/19/recent-changes-in-node-js-modules-support/
You have probably installed the module globally, which is fine for local development but you need to deploy the application with the module.
Before deploying via vmc, run npm install in the project directory.