I have installed Parse Server on Heroku and forked the Parse Server Example. When I git push heroku master I get the error
"You must provide an appIp!"
Error log:
019-03-20T11:03:56.517489+00:00 heroku[web.1]: Starting process with command `npm start`
2019-03-20T11:03:59.418738+00:00 app[web.1]:
2019-03-20T11:03:59.418754+00:00 app[web.1]: > parse-server-example#1.4.0 start /app
2019-03-20T11:03:59.418756+00:00 app[web.1]: > node index.js
2019-03-20T11:03:59.418757+00:00 app[web.1]:
2019-03-20T11:04:01.887096+00:00 heroku[web.1]: State changed from starting to crashed
2019-03-20T11:04:01.724008+00:00 app[web.1]:
2019-03-20T11:04:01.724030+00:00 app[web.1]: /app/node_modules/parse-server/lib/ParseServer.js:218
2019-03-20T11:04:01.724032+00:00 app[web.1]: throw err;
2019-03-20T11:04:01.724033+00:00 app[web.1]: ^
2019-03-20T11:04:01.724105+00:00 app[web.1]: You must provide an appId!
2019-03-20T11:04:01.779713+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-03-20T11:04:01.780520+00:00 app[web.1]: npm ERR! errno 7
2019-03-20T11:04:01.782955+00:00 app[web.1]: npm ERR! parse-server-example#1.4.0 start: `node index.js`
2019-03-20T11:04:01.783173+00:00 app[web.1]: npm ERR! Exit status 7
2019-03-20T11:04:01.783716+00:00 app[web.1]: npm ERR!
2019-03-20T11:04:01.783983+00:00 app[web.1]: npm ERR! Failed at the parse-server-example#1.4.0 start script.
2019-03-20T11:04:01.784194+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-03-20T11:04:01.804701+00:00 app[web.1]:
2019-03-20T11:04:01.805007+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-03-20T11:04:01.805196+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-03-20T11_04_01_786Z-debug.log
2019-03-20T11:04:01.866235+00:00 heroku[web.1]: Process exited with status 7
index.js:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
if (!databaseUri) {
console.log('DATABASE_URI not specified, falling back to localhost.');
}
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://key
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || 'myMasterKey',
serverURL: process.env.SERVER_URL || 'http://myApp.herokuapp.com/parse',
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
}
});
var server = ParseServer({
verifyUserEmails: true,
publicServerURL: 'myApp.herokuapp.com/parse',
appName: 'myAppName',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'parse#example.com',
domain: 'domainFromMailGun.mailgun.org',
apiKey: 'myAPIKey',
}
}
});
I have provided the appId in appId: process.env.APP_ID || 'myAppId', or am I missing something here? Does the appId have to provided elsewhere?
First of all, please invalidate those MongoDB credentials immediately. They are forever compromised, and you need to generate new ones. Editing them out of your question is not enough.
I'm not totally clear on what you're trying to do here, but you're actually instantiating two Parse servers. You do provide an appId for the first one (api), but not for the second (server).
You probably only need one Parse Server. If you do actually need two for some reason, each one will need an appId.
Related
I'm getting npm ERR! code ELIFECYCLE when I try to run my server command
What I'm trying to do is
TensorFlow.js Training in Node.js
It's for college, step 3 says to try out the server I get this
package.json snip
"scripts": {
"start-client": "webpack && webpack-dev-server",
"start-server": "node server.js"
},
error message
C:\xampp\htdocs\leo\baseball>npm run start-server
> tfjs-examples-baseball-node#0.2.0 start-server C:\xampp\htdocs\leo\baseball
> node server.js
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: Não foi possível encontrar o módulo especificado.
\\?\C:\xampp\htdocs\leo\baseball\node_modules\#tensorflow\tfjs-node\lib\napi-v5\tfjs_binding.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\xampp\htdocs\leo\baseball\node_modules\#tensorflow\tfjs-node\dist\index.js:58:16)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tfjs-examples-baseball-node#0.2.0 start-server: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tfjs-examples-baseball-node#0.2.0 start-server 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! C:\Users\Usuário\AppData\Roaming\npm-cache\_logs\2020-12-11T07_01_54_120Z-debug.log
server.js
require('#tensorflow/tfjs-node');
const http = require('http');
const socketio = require('socket.io');
const pitch_type = require('./pitch_type');
const TIMEOUT_BETWEEN_EPOCHS_MS = 500;
const PORT = 8001;
// util function to sleep for a given ms
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Main function to start server, perform model training, and emit stats via the socket connection
async function run() {
const port = process.env.PORT || PORT;
const server = http.createServer();
const io = socketio(server);
server.listen(port, () => {
console.log(` > Running socket on port: ${port}`);
});
io.on('connection', (socket) => {
socket.on('predictSample', async (sample) => {
io.emit('predictResult', await pitch_type.predictSample(sample));
});
});
let numTrainingIterations = 10;
for (var i = 0; i < numTrainingIterations; i++) {
console.log(`Training iteration : ${i+1} / ${numTrainingIterations}`);
await pitch_type.model.fitDataset(pitch_type.trainingData, {epochs: 1});
console.log('accuracyPerClass', await pitch_type.evaluate(true));
await sleep(TIMEOUT_BETWEEN_EPOCHS_MS);
}
io.emit('trainingComplete', true);
}
run();
I already tried:
cache clean --force/-f, delete node_modules package-lock.json run npm install
removing package-lock.json and running the server
npm install -g node-pre-gyp
npm install --unsafe-perm
Changing the port from 8001 to 10000 3000 80
running it with every single thing else on my computer closed (this includes my xampp on the bg)
some info
node -v 14.15.1
npm -v 6.14.8
windows 10 x64
My grade needs me to overcome this and finish the tutorial
line 13 of my error accused something wrong at line 58 at this file
at Object.<anonymous> (C:\xampp\htdocs\leo\baseball\node_modules\#tensorflow\tfjs-node\dist\index.js:58:16)
opened the file and commented the line, code ran without problems
I have deployed a simple Nodejs app to Heroku and I keep getting an error in the application logs saying that the module "mongoose" cannot be found. I even provided a relative path instead of just saying require("mongoose"). The deployment succeeds and installs all the dependencies. The source code can be found here https://github.com/collinkleest/trim-io.
Here is the error log from heroku.
2020-10-17T02:01:42.000000+00:00 app[api]: Build started by user collinkleest#gmail.com
2020-10-17T02:01:59.000000+00:00 app[api]: Build succeeded
2020-10-17T02:01:59.493929+00:00 app[api]: Deploy af985be5 by user collinkleest#gmail.com
2020-10-17T02:01:59.493929+00:00 app[api]: Release v14 created by user collinkleest#gmail.com
2020-10-17T02:01:59.652847+00:00 heroku[web.1]: State changed from crashed to starting
2020-10-17T02:02:01.917601+00:00 heroku[web.1]: Starting process with command `npm start`
2020-10-17T02:02:04.175589+00:00 app[web.1]:
2020-10-17T02:02:04.175612+00:00 app[web.1]: > trim-io#0.0.1 start /app
2020-10-17T02:02:04.175612+00:00 app[web.1]: > node server.js
2020-10-17T02:02:04.175613+00:00 app[web.1]:
2020-10-17T02:02:04.369536+00:00 app[web.1]: internal/modules/cjs/loader.js:834
2020-10-17T02:02:04.369538+00:00 app[web.1]: throw err;
2020-10-17T02:02:04.369539+00:00 app[web.1]: ^
2020-10-17T02:02:04.369539+00:00 app[web.1]:
2020-10-17T02:02:04.369539+00:00 app[web.1]: Error: Cannot find module '../node_modules/mongoose'
2020-10-17T02:02:04.369540+00:00 app[web.1]: Require stack:
2020-10-17T02:02:04.369540+00:00 app[web.1]: - /app/models/urlEntity.js
2020-10-17T02:02:04.369541+00:00 app[web.1]: - /app/server.js
2020-10-17T02:02:04.369541+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
2020-10-17T02:02:04.369542+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2020-10-17T02:02:04.369542+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:903:19)
2020-10-17T02:02:04.369543+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-10-17T02:02:04.369543+00:00 app[web.1]: at Object.<anonymous> (/app/models/urlEntity.js:1:18)
2020-10-17T02:02:04.369543+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-10-17T02:02:04.369544+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-10-17T02:02:04.369544+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-10-17T02:02:04.369545+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-10-17T02:02:04.369545+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:903:19) {
2020-10-17T02:02:04.369545+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-10-17T02:02:04.369546+00:00 app[web.1]: requireStack: [ '/app/models/urlEntity.js', '/app/server.js' ]
2020-10-17T02:02:04.369546+00:00 app[web.1]: }
2020-10-17T02:02:04.389361+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-10-17T02:02:04.389827+00:00 app[web.1]: npm ERR! errno 1
2020-10-17T02:02:04.398788+00:00 app[web.1]: npm ERR! trim-io#0.0.1 start: `node server.js`
2020-10-17T02:02:04.399025+00:00 app[web.1]: npm ERR! Exit status 1
2020-10-17T02:02:04.399280+00:00 app[web.1]: npm ERR!
2020-10-17T02:02:04.399493+00:00 app[web.1]: npm ERR! Failed at the trim-io#0.0.1 start script.
2020-10-17T02:02:04.399722+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-10-17T02:02:04.420468+00:00 app[web.1]:
2020-10-17T02:02:04.420707+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-10-17T02:02:04.420857+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-10-17T02_02_04_400Z-debug.log
2020-10-17T02:02:04.487055+00:00 heroku[web.1]: Process exited with status 1
2020-10-17T02:02:04.554273+00:00 heroku[web.1]: State changed from starting to crashed
Here is my server.js for reference as well:
const express = require("express");
const UrlEntity = require("./models/urlEntity");
const mongoose = require("./node_modules/mongoose");
const urlEntity = require("./models/urlEntity");
const app = express();
require('dotenv').config();
const mongoUri = "mongodb+srv://" + process.env.MONGO_USR + ":" + process.env.MONGO_PASS + "#" + process.env.MONGO_URL + "/" + process.env.MONGO_DB + "?retryWrites=true&w=majority";
mongoose.connect(
mongoUri,
{ useNewUrlParser: true, useUnifiedTopology: true}
);
app.use(express.json());
app.use(express.static('public'));
async function checkIdExists(id){
let exists = await UrlEntity.exists({uniqueId: id});
return exists;
}
function generateId(){
let randomId = Math.random().toString(20).substr(2, 8);
while(!(checkIdExists(randomId))){
randomId = Math.random().toString(20).substr(2, 8);
}
return randomId;
}
// redirect functionality
app.get("/:id", async (req, res) => {
if (req.params.id !== null || req.params.id !== undefined){
let doc = await UrlEntity.findOne({uniqueId: req.params.id});
res.redirect(doc.targetUrl);
} else {
res.redirect('/');
}
});
// create new url
app.post("/create-url", async (req, res) => {
console.log("in post");
let id = generateId();
await UrlEntity.create({uniqueId: id,
targetUrl: req.body.url,
dateCreated: req.body.date});
res.send(`${req.protocol}://${req.get('host')}/${id}`);
});
app.listen(process.env.PORT || 5000, () => {console.log("Trim.io API Started")});
You put mongoose in your devDependencies, which will be removed at runtime. (Link from your code) You need to move it to dependencies so that it will be available at runtime.
try changing the const mongoose = require("./node_modules/mongoose")
back to const mongoose = require("mongoose");
Don't forget to set your environment variables MONGO_USR, MONGO_PASS e.t.c on heroku settings. Your server will not start if the environment variable is not set.
Lastly I advice you use a connection string like this mongodb+srv://user:password#cluster2.bftwu.mongodb.net/databaseName
without concatenating
I'm trying to host a Discord bot for the first time through Heroku (also my first time using the site). It was running perfectly locally, but I started receiving errors in regards to the $PORT once I went online. When I looked that up, I saw I needed to listen to the server in order for the port to stick, but every attempt I've done results in the EADDRINUSE error. I've looked over and tried many examples through these previous answers here and here, deleted modules and reinstalled them countless times, ended node.exe processes before booting up, but I keep running into the error. I must be missing something but I can't figure it out and I feel like I'm just running in circles. Any help would be appreciated.
The error report:
2020-07-28T21:24:01.605923+00:00 heroku[web.1]: Starting process with command `npm start`
2020-07-28T21:24:03.399990+00:00 app[web.1]:
2020-07-28T21:24:03.400006+00:00 app[web.1]: > bot#1.0.0 start /app
2020-07-28T21:24:03.400006+00:00 app[web.1]: > node bot.js
2020-07-28T21:24:03.400006+00:00 app[web.1]:
2020-07-28T21:24:04.323323+00:00 app[web.1]: Ready!
2020-07-28T21:24:06.981374+00:00 app[web.1]: Listening on 50667
2020-07-28T21:24:07.141720+00:00 app[web.1]: events.js:292
2020-07-28T21:24:07.141721+00:00 app[web.1]: throw er; // Unhandled 'error' event
2020-07-28T21:24:07.141722+00:00 app[web.1]: ^
2020-07-28T21:24:07.141722+00:00 app[web.1]:
2020-07-28T21:24:07.141724+00:00 app[web.1]: Error: listen EADDRINUSE: address already in use :::50667
2020-07-28T21:24:07.141725+00:00 app[web.1]: at Server.setupListenHandle [as _listen2] (net.js:1313:16)
2020-07-28T21:24:07.141725+00:00 app[web.1]: at listenInCluster (net.js:1361:12)
2020-07-28T21:24:07.141726+00:00 app[web.1]: at Server.listen (net.js:1447:7)
2020-07-28T21:24:07.141727+00:00 app[web.1]: at Function.listen (/app/node_modules/express/lib/application.js:618:24)
2020-07-28T21:24:07.141727+00:00 app[web.1]: at Client.<anonymous> (/app/bot.js:21075:4)
2020-07-28T21:24:07.141727+00:00 app[web.1]: at Client.emit (events.js:315:20)
2020-07-28T21:24:07.141743+00:00 app[web.1]: at MessageCreateAction.handle (/app/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
2020-07-28T21:24:07.141745+00:00 app[web.1]: at Object.module.exports [as MESSAGE_CREATE] (/app/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
2020-07-28T21:24:07.141752+00:00 app[web.1]: at WebSocketManager.handlePacket (/app/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
2020-07-28T21:24:07.141752+00:00 app[web.1]: at WebSocketShard.onPacket (/app/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
2020-07-28T21:24:07.141753+00:00 app[web.1]: Emitted 'error' event on Server instance at:
2020-07-28T21:24:07.141753+00:00 app[web.1]: at emitErrorNT (net.js:1340:8)
2020-07-28T21:24:07.141753+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:84:21) {
2020-07-28T21:24:07.141754+00:00 app[web.1]: code: 'EADDRINUSE',
2020-07-28T21:24:07.141754+00:00 app[web.1]: errno: 'EADDRINUSE',
2020-07-28T21:24:07.141755+00:00 app[web.1]: syscall: 'listen',
2020-07-28T21:24:07.141755+00:00 app[web.1]: address: '::',
2020-07-28T21:24:07.141756+00:00 app[web.1]: port: 50667
2020-07-28T21:24:07.141756+00:00 app[web.1]: }
2020-07-28T21:24:07.154255+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-07-28T21:24:07.154464+00:00 app[web.1]: npm ERR! errno 1
2020-07-28T21:24:07.157313+00:00 app[web.1]: npm ERR! bot#1.0.0 start: `node bot.js`
2020-07-28T21:24:07.157445+00:00 app[web.1]: npm ERR! Exit status 1
2020-07-28T21:24:07.157646+00:00 app[web.1]: npm ERR!
2020-07-28T21:24:07.157759+00:00 app[web.1]: npm ERR! Failed at the bot#1.0.0 start script.
2020-07-28T21:24:07.157832+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-07-28T21:24:07.169750+00:00 app[web.1]:
2020-07-28T21:24:07.169882+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-07-28T21:24:07.169957+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-07-28T21_24_07_159Z-debug.log
2020-07-28T21:24:07.254000+00:00 heroku[web.1]: State changed from starting to crashed
2020-07-28T21:24:07.225012+00:00 heroku[web.1]: Process exited with status 1
package.json
{
"name": "bot",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"discord.js": "^12.2.0",
"exit-hook": "^2.2.0",
"express": "^4.17.1",
"http": "0.0.1-security",
"webpack-dev-server": "^3.11.0"
},
"scripts": {
"start": "node bot.js",
"stop-win": "Taskkill /IM node.exe /F"
},
"main": "bot.js",
"devDependencies": {},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}
Current code (though I have tried many different ones as well.)
const express = require('express');
const path = require('path');
const PORT = process.env.PORT || 5000;
express()
.use(express.static(path.join(__dirname, 'public')))
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs')
.get('/', (req, res) => res.render('pages/index'))
.listen(PORT, () => console.log(`Listening on ${ PORT }`));
},);
I understand that I should probably run the bot as a Worker instead of Web through Heroku, but the option is not available to me for some reason and my Procfile was doing nothing.
I know there must be something I'm overlooking. When I run the stop-win script, it kills two node.exe processes even when I try running the code only once.
I've been looking at this for too long (days!) and keep going in circles, I need some fresh eyes and ideas. Please help!
EDIT:
Thanks Tin Nguyen for pointing me in the right direction for the Procfile! I was able to use this thread to make an echo, and thus a functioning Procfile making it a worker. This let me fix all of the mess. Thank you very much!
I think the error is comming from the port! look at the errors,
Ready!
Listening on 50667
events.js:292
throw er; // Unhandled 'error' event
Error: listen EADDRINUSE: address already in use :::50667
it says "address already in use", try to change it and let me noticied if it works!
I am trying to deploy a simple Ecommerce website that has Reactjs , Node, Express and MongoDB. I have followed a tutorial to deploy it to the heroku. I have used babel but in the tutorial, it wasn't used. I know we don't use babel for production and used only for the development purpose, but I am not sure how I would still deploy my website.
The server is working perfectly locally and also the Heroku build is successful. But when I visit my deployed app on heroku it says application error.
Here are the logs from Heroku:
2020-06-29T16:04:44.812179+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-29T16:04:48.072669+00:00 app[web.1]:
2020-06-29T16:04:48.072690+00:00 app[web.1]: > e-commerce-site#1.0.0 start /app
2020-06-29T16:04:48.072691+00:00 app[web.1]: > babel-node backend/server.js
2020-06-29T16:04:48.072691+00:00 app[web.1]:
2020-06-29T16:04:48.105827+00:00 app[web.1]: sh: 1: babel-node: not found
2020-06-29T16:04:48.110266+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-06-29T16:04:48.111030+00:00 app[web.1]: npm ERR! syscall spawn
2020-06-29T16:04:48.111915+00:00 app[web.1]: npm ERR! file sh
2020-06-29T16:04:48.112482+00:00 app[web.1]: npm ERR! errno ENOENT
2020-06-29T16:04:48.114018+00:00 app[web.1]: npm ERR! e-commerce-site#1.0.0 start: `babel-node backend/server.js`
2020-06-29T16:04:48.114155+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-06-29T16:04:48.114342+00:00 app[web.1]: npm ERR!
2020-06-29T16:04:48.114508+00:00 app[web.1]: npm ERR! Failed at the e-commerce-site#1.0.0 start script.
2020-06-29T16:04:48.114601+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-06-29T16:04:48.133545+00:00 app[web.1]:
2020-06-29T16:04:48.134148+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-06-29T16:04:48.134771+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-06-
29T16_04_48_124Z-debug.log
2020-06-29T16:04:48.213867+00:00 heroku[web.1]: Process exited with status 1
2020-06-29T16:04:48.265610+00:00 heroku[web.1]: State changed from starting to crashed
2020-06-29T16:04:48.268292+00:00 heroku[web.1]: State changed from crashed to starting
2020-06-29T16:04:57.328678+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-29T16:05:00.299582+00:00 app[web.1]:
2020-06-29T16:05:00.299595+00:00 app[web.1]: > e-commerce-site#1.0.0 start /app
2020-06-29T16:05:00.299595+00:00 app[web.1]: > babel-node backend/server.js
2020-06-29T16:05:00.299596+00:00 app[web.1]:
2020-06-29T16:05:00.308802+00:00 app[web.1]: sh: 1: babel-node: not found
2020-06-29T16:05:00.312668+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-06-29T16:05:00.313206+00:00 app[web.1]: npm ERR! syscall spawn
2020-06-29T16:05:00.313637+00:00 app[web.1]: npm ERR! file sh
2020-06-29T16:05:00.314093+00:00 app[web.1]: npm ERR! errno ENOENT
2020-06-29T16:05:00.315953+00:00 app[web.1]: npm ERR! e-commerce-site#1.0.0 start: `babel-node backend/server.js`
2020-06-29T16:05:00.316283+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-06-29T16:05:00.316613+00:00 app[web.1]: npm ERR!
2020-06-29T16:05:00.316974+00:00 app[web.1]: npm ERR! Failed at the e-commerce-site#1.0.0 start script.
2020-06-29T16:05:00.317312+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-06-29T16:05:00.344371+00:00 app[web.1]:
2020-06-29T16:05:00.344828+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-06-29T16:05:00.345202+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-06-29T16_05_00_319Z-debug.log
2020-06-29T16:05:00.406294+00:00 heroku[web.1]: Process exited with status 1
2020-06-29T16:05:00.466244+00:00 heroku[web.1]: State changed from starting to crashed
File Name: Server.js
The file where I have all the connections for MongoDB:
import express from "express";
import data from "./data";
import dotenv from "dotenv";
import config from "./config";
import mongoose from "mongoose";
import userRoute from "./routes/userRoute";
import productRoute from "./routes/productRoute";
import bodyParser from "body-parser";
dotenv.config();
const mongodbUrl = config.MONGODB_URL;
const PORT = process.env.PORT || 5000;
mongoose.connect(mongodbUrl , {
useNewUrlParser : true,
useUnifiedTopology: true,
useCreateIndex: true
}).catch(error => console.log(error.reason));
const app = express();
app.use(bodyParser.json());
app.use("/api/users" , userRoute);
app.use("/api/products" , productRoute);
if (process.env.NODE_ENV === "production"){
app.use(express.static("./frontend/build"));
}
app.listen(PORT , console.log(`Server started at ${PORT}`));
File Name: config.js
export default{
MONGODB_URL: process.env.MONGODB_URL || "mongodb://localhost/ecommercesite",
JWT_SECRET: process.env.JWT_SECRET || "somethingsecret"
}
File Name: Package.json
{
"name": "e-commerce-site",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build" : "cd frontend && npm run build",
"install-client" : "cd frontend && npm install",
"heroku-postbuild" : "npm run install-client && npm run build",
"start": "babel-node backend/server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.9.16"
},
"devDependencies": {
"#babel/cli": "^7.10.1",
"#babel/core": "^7.10.1",
"#babel/node": "^7.10.1",
"#babel/preset-env": "^7.10.1",
"nodemon": "^2.0.4"
}
}
I tried everything I could find, but I can't get my deployment to work. I keep getting 'Application Error', although the app runs on my http://localserver:5000
Seems the problem is in bin/www
Here is the error log i get in Heroku. I suppose the issue is "Port 34037 is already in use"
pp[web.1]: > tubka#0.0.0 start /app
2015-02-04T09:29:03.327577+00:00 app[web.1]: > node ./bin/www
2015-02-04T09:29:03.327578+00:00 app[web.1]:
2015-02-04T09:29:03.695715+00:00 app[web.1]: http server listening on 34037
2015-02-04T09:29:03.761305+00:00 app[web.1]: npm ERR! You can get their info via:
2015-02-04T09:29:03.744365+00:00 app[web.1]: Port 34037 is already in use
2015-02-04T09:29:03.761400+00:00 app[web.1]: npm ERR! npm owner ls tubka
2015-02-04T09:29:03.759922+00:00 app[web.1]: npm ERR! tubka#0.0.0 start: `node ./bin/www`
2015-02-04T09:29:03.761610+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-02-04T09:29:03.760193+00:00 app[web.1]: npm ERR!
2015-02-04T09:29:03.762242+00:00 app[web.1]: npm ERR! command "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-02-04T09:29:03.760053+00:00 app[web.1]: npm ERR! Exit status 1
2015-02-04T09:29:03.762111+00:00 app[web.1]: npm ERR! System Linux 3.13.0-40-generic
2015-02-04T09:29:03.760836+00:00 app[web.1]: npm ERR! This is most likely a problem with the tubka package,
2015-02-04T09:29:03.762374+00:00 app[web.1]: npm ERR! cwd /app
2015-02-04T09:29:03.760300+00:00 app[web.1]: npm ERR! Failed at the tubka#0.0.0 start script.
2015-02-04T09:29:03.762511+00:00 app[web.1]: npm ERR! node -v v0.10.35
2015-02-04T09:29:03.760965+00:00 app[web.1]: npm ERR! not with npm itself.
2015-02-04T09:29:03.762654+00:00 app[web.1]: npm ERR! npm -v 1.4.28
2015-02-04T09:29:03.761073+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-02-04T09:29:03.762777+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-02-04T09:29:03.761194+00:00 app[web.1]: npm ERR! node ./bin/www
2015-02-04T09:29:03.766267+00:00 app[web.1]: npm ERR! Additional logging details can be found in:
2015-02-04T09:29:03.766925+00:00 app[web.1]: npm ERR! not ok code 0
2015-02-04T09:29:03.766121+00:00 app[web.1]: npm ERR!
2015-02-04T09:29:03.766678+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2015-02-04T09:29:03.718169+00:00 app[web.1]: websocket server created
2015-02-04T09:29:03.753343+00:00 app[web.1]:
2015-02-04T09:29:04.473160+00:00 heroku[web.1]: Process exited with status 1
2015-02-04T09:29:04.482618+00:00 heroku[web.1]: State changed from starting to crashed
2015-02-04T09:29:59.234120+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=tubka.herokuapp.com request_id=4edf0fd1-1231-440b-ac4a-4a21733e623f fwd="88.192.84.193" dyno= connect= service= status=503 bytes=
2015-02-04T09:30:00.283732+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=tubka.herokuapp.com request_id=3fdcf81e-c40f-4770-ae0f-d83a7e672d1f fwd="88.192.84.193" dyno= connect= service= status=503 bytes=
Internetz:gagtube alexandertazh$
I am following the Heroku docs to deploy websockets with ws module.
Here is part of my app.js Nore the part var port = process.env.PORT || 5000
**var express = require('express')
var http = require("http");
var Crawler = require("simplecrawler");
var cheerio = require('cheerio');
var fs = require('fs');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var app = express();
var port = process.env.PORT || 5000
var server = http.createServer(app)
server.listen(port)
console.log("http server listening on %d", port)
var WebSocketServer = require('ws').Server
var wss = new WebSocketServer({server: server})
console.log("websocket server created")
wss.on("connection", function(ws) {
fs.readFile('./playlist.json', 'utf-8', function(err, data){
if (err) throw err;
ws.send(data);
console.log(data);
});
console.log("websocket connection open")
ws.on("close", function() {
console.log("websocket connection close")
})
})**
And client-side:
var host = location.origin.replace(/^http/, 'ws')
var ws = new WebSocket(host);
ws.onmessage = function (event) {
playthelistclient.push(event.data);
};
My bin/www file part concerning ports:
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
Hope you guys can help.
Comment out the stuff related to ports in www file, because you already have that stuff in your app.js file:
//var port = normalizePort(process.env.PORT || '3000');
//app.set('port', port);
//server.listen(port);