When deploying, Heroku fails to provide specific PORT information

Here is my index.js file:

const PORT = process.env.PORT || 8453;

app.listen(PORT, () => console.log("Server is now listening on port: " + PORT));

However, when checking the deploy logs, I see:

Running build (yarn)
yarn run v1.22.4
$ node src/index.js
Server is now listening on port: 8453

Answer №1

When executing the code on your own machine, this is the log you will see. However, the logs appear differently on Heroku.

Answer №2

Hey there!

Did you know that Heroku actually doesn't allow the use of .env files? Instead, you can utilize "Config vars" in your project configuration, which essentially serves as the equivalent to .env/process.env on Heroku.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Searching text with jQuery filter can be delayed when backspacing

When utilizing jQuery filter to search for names in a large list, it performs well with high speed when typing in the input field. However, upon pressing the backspace button to clear the search text, there is a noticeable delay of over 4 seconds when ther ...

Form submission results in $_POST[] variable being blank

I am trying to create a basic PHP form with two textboxes, a dropdown list, and a SUBMIT button. Before submitting the form, the user must choose an item from the dropdown list. Once an item is selected, the other two textboxes are automatically filled wit ...

What is the best way to insert a hyperlink into a specific piece of text?

Here is a list of elements: <ul> <li> <a href="#link1">Text link 1</a> <span>My text contains text: Text link 1, that's it.</span> </li> <li> <a href="#link2">Text link 2</a ...

Error encountered: Unable to access attributes of an object that is not defined (specifically trying to read 'clientX')

Hey there! I'm having some trouble moving figures while moving the cursor. It's strange because I've done the same thing on another page and it worked perfectly: const scaleFactor = 1 / 20; function moveItems(event) { const shapes = do ...

Learn the technique of rotating a line around its endpoint using DragControls in three.js

I made a custom modification to DragControls.js so that it only allows movement of the line on the y-axis. Here is the line setup I am using: material = new THREE.LineBasicMaterial( { color: 0xFF0000 } ); geometry.vertices.push(new THREE.Vector3( 0, 0, 0 ...

Exploring the possibilities of retrieving user information through aggregation in Node.js using a REST API

function findUserDetailsById(reqUserId) { dbo.collection('user').aggregate([ { $lookup: { from: 'usersettings', localField: '_id', foreignFiel ...

I am having trouble getting text to display properly in a jQuery Mobile dialog

I am attempting to dynamically set the header and button texts using JavaScript, but unfortunately it's not working as expected. To demonstrate the issue, I have added my code on jsfiddle: http://jsfiddle.net/tMKD3/8/. Here is the HTML code: <bod ...

Proper utilization of ngIf in conjunction with mat-cell

I am attempting to show a specific value only if the item possesses a certain property, but I keep seeing [object Object] instead. Here is my current method: <ng-container matColumnDef="name"> <th mat-header-cell *matHeaderCellDe ...

"Exploring the Backbone collection object in our browser's developer console

When I log one of my Backbone collections, the object summary shows that the length is 0 and the models array is empty. However, in the dropdown detail, it displays the correct length and model array. When I run console.log(this.collection.models), it re ...

Having trouble establishing a connection between Elmah and mongoDB in a webApi environment

Currently, I am working on a project that involves an ASP.NET WebAPI2 framework and uses MongoDB to store some basic data using entity framework. For error handling purposes, I always integrate ELMAH into my ASP.NET projects. I downloaded the MongoDB versi ...

Gremlin, can you tell me where the "valueMap()" function has been imported from in JavaScript?

Working with ES6 on Node.js, I am attempting to execute the project() step within a Gremlin query. For this projection, my goal is to extract the properties. In the Gremlin console, I would typically use valueMap() to retrieve these properties. However, ...

React: How to retrieve values from a dynamic dropdown menu

For my React project, I have integrated ant design components. Currently, I am working on adding dynamic select functionality and retrieving the selected values. I have successfully implemented dynamic dropdown selection. However, I am facing an issue wi ...

While executing a for loop, the variable $.ajax is found to be null in Javascript

When I click on a button with the function btn-book, there is a for loop inside it that fetches data from Ajax. Despite knowing that the data holds values, I constantly receive null. Below is the code snippet for the onclick event: $('#mapContainer&a ...

Utilize RequireJS to modularize scripts in an organized manner

Recently, I was working on a web application and wanted to organize it into modules. After some research, I discovered that RequireJS is the most suitable tool for this task. By reading documentation and tutorials, I managed to come up with the following c ...

Having trouble getting AngularJS ngCloak to function properly?

My post category page is supposed to display a message if there are no posts. However, the HTML appears briefly when the page loads and then hides. I thought using ngCloak would solve this issue, but it doesn't seem to be working for me. Here's t ...

Converting Boolean Values to Strings in Ionic/Angular NGX Datatable

Currently, I am working on a project to develop an Ionic/Angular application. For this application, I am utilizing NGX datatable which is functioning well. However, I have a specific requirement - I need to display boolean values in German instead of Engli ...

Is it no longer necessary to bind functions in React Component Classes?

Recently, I observed that when defining normal class component functions in React, there is no longer a need to bind them inside the class constructor. This means that even without using ES6 public class field syntax, you can simply pass these functions to ...

Tips for incorporating CSS animation onto a distinct item that is being re-rendered in React

Is there a way to trigger a CSS animation every time the stock property of an item in the state increases due to a button click in React? Here is the React code snippet: const RenderingApp = () => { const [items, setItems] = useState([ { fruit: ...

Ways to include additional parameters in jQuery ajax success and error callbacks

When working with a jQuery AJAX success/error function similar to the following: success: function (data, textStatus, jqXHR) { } error: function (jqxr, errorCode, errorThrown) { } I am wondering if there is a method where I can pass an array of valu ...

An error has occurred: The transport specified is invalid and must be an object containing a log method

Issue: I am facing a problem while trying to run the node server.js file to execute a port listening http_server. It seems like the code is not working properly. Can someone please help me resolve this issue? var socket = require('socket.io'), ...