I've deployed my app on Heroku and I have an express script that should wait for a post request. I need to run it separately on Heroku. When I open the console on Heroku and type:
heroku run bash node scripts/start_express.js
I get the following error:
/app/.heroku/node/bin/node: /app/.heroku/node/bin/node: cannot execute binary file
How do I use node to run my js file on Heroku?
The node buildpack for heroku will automatically look for npm start script in your package.json file. That is where you can specify which file to serve up. Check this article out for some help on node and heroku https://devcenter.heroku.com/articles/nodejs-support
Related
I have a project that uses express and react. I'm deploying it to heroku but after running git push, I receive an error in heroku logs. I go to the specified webpage and it says that it cannot find a buildpack. What do I do? Any help will be appreciated!
you need to go this way: Settings -> Add buildpack -> node.js
don't forget, that this is only start and you may need to add some scripts in your package.json file for heroku deployment process
So, I searched a lot before asking this here as I was not able to find a single answer related to this small problem.
I want to run node.js file on my heroku server which is on free-tier but I don't want to use node file.js. I want to use forever start file.js.
So, I did wrote the commands in my package files as well as defined a Procfile for worker: forever start file.js.
And deployed to heroku, but all the logs says that
forever: bash command not found.
Any solution ?
I have a node.js file that runs locally when I run it and it sends the user a text notification via the Twilio service. However, I'm trying to deploy it to my AWS Ubuntu server (EC2) so I can use it now on my actual website, but I'm not sure how to upload a local file to my instance like I did when I was following this tutorial (https://hackernoon.com/tutorial-creating-and-managing-a-node-js-server-on-aws-part-1-d67367ac5171) when I initially mkdir server and then cd into it which ultimately contained index.js, node_modules, and server file.
Now on my local folder, it also contains a folder called node_modules that currently has an express folder and a Twilio helper folder. So would I have to put the Twilio folder within the node_modules folder in AWS and is there a way to do this through the Terminal?
Additionally, I was curious if my app.js (Node) file would even function if my Twilio file is hosted on a GoDaddy server? I hope I made sense and any help is appreciated.
You can use the rsync command line utility (available on Linux, Mac, but also on Windows with Cygwin).
The way you'd use it is:
rsync -e 'ssh -i YOUR_AWS_KEY.pem' -avh /path/to/your/local/folder YOUR_AWS_USER#YOUR_AWS_HOSTNAME:/your/remote/path
I have a node.js application that uses the python-shell module. When I start the app with the command: node server.js everything works well, including Python scripts. If I try to start the application with the pm2 start logs server command, Python scripts do not work and I get a lot of errors on PythonShell, Object.callPythonScript.
Does anyone know how to fix and how does the application normally work with the node compiler, but not with pm2?
This is the logs error:
I have a simple Angular 4 frontend as well as a node backend which is hosted separately on Heroku.
I deploy my Angular app by running ng build and copying over the contents of the dist folder to the server.
I have since then decided to integrate the backend into the front end so it's all just one project instead of two.
I can easily run node server.js on the root and it runs perfectly on my localhost.
But how can I deploy this to my server? I obviously can't just ng build and copy over the dist folder because that only builds the client folders and files.
Could I just copy over the server folder which holds the routes as well as the server.js file along with the client files and then somehow tell the server to run server.js when the site is loaded?
I use FileZilla to transfer my files onto the server.
Questions:
How do I deploy my angular/node app with FileZilla?
Which files/folders to I copy over with the client files?
If you are using Angular CLI, run ng build command to generate the dist folder.
Copy the dist folder to the backend server nodejs project.
Serve the dist folder using your Nodejs code.
If you are using ExpressJS. This can be done in a single line
app.use(express.static('dist'));
Install Heroku CLI and follow the tutorial to deploy your app: Heroku NodeJS Tutorial
You don't need to build the node app. Node runtime can compile the javascript on the fly.
The build step in angular packages up your code into one file. There is no equivalent in node as there isn't any point. The reason angular minifies and packages a file is so you can download it quickly. You never download the code from node.
On Heroku it's really easy, you don't need to copy anything over just run git push heroku master from the root of your node folder as per the instructions here https://devcenter.heroku.com/articles/getting-started-with-nodejs#deploy-the-app
Just make sure that in your package.json you have all the modules you rely on. It might work locally if you have npm modules installed globally but they also need to be in the package.json so heroku can download them by running npm install