How to deploy Node.js / Express app with typescript on heroku? - node.js

I want to deploy node.js / express server app on heroku.
I tried with this blog.
But it didn't work. The parts of my code are below.
server.ts
package.json

Ahh. You have messed up in the package.json file. What you have done is you have included the dependencies in the devDependencies.
Remember one thing always, when you are going to push an app to Heroku it prunes the devDependencies.
Actually, this is the main cause your server is not starting up because there are not required modules.
Run this command to move your devDependencies to dependencies:
npm install <module-name> --save-dev
This thing will solve your problem. If you face any other problem related to the configuration then follow this article - https://dev.to/hte305/simple-deploy-typescript-application-to-heroku-5b6g

Related

Is it relevant to use dev dependencies in a Node / Express backend?

I understand using package.json dev dependencies when you build your code. But if your application is an Express backend, does it make any difference using dev or regular dependencies in package.json?
An example of a backend dev dependency I would use is nodemon.
The only thing I can think of is that hosting providers might somehow install only non-dev dependencies when running, but I can't find details if that actually happens.

"npm run build" Command in an Express App Colliding on Imports with Typescript and React Native

I have an Express app that I build and run using npm run serve which I define in my package.json scripts serve section as: 'npm run build && node lib/index.js'. Recently, I installed React Native for another project, however, when I return to my express project and attempt to build it with npm run build, I recieve multiple duplicate declaration errors in the terminal:
React Native is not defined anywhere in my Express project, when I examine my node modules, there is no react-native package even installed. Before installing React Native in another project this command worked fine, the Express project has not been changed since it last compiled succefully.
Thanks #TheGreatZab for testing it out.
Post the answer here to help anyone who are suffering from this problem.
The reason is an extra node_modules/package.json exist in grand parent directories which trigger the butterfly effects.
Solution:
Remove the node_modules, package.json from parent/grand parent directories

How to run NodeJS+MongoDB project?

I have experience of run node.js project.
It contains package.json and I use npm install command. and run node app.js after installation.
Please see this project: https://github.com/krutt/Wild-Ones
It's node.js project. But I can't install this. It has no package.json file.
How can I deploy this server on my computer?
Please help.
Correct, there's no package.json, so it's not a ready-to-deploy project. You would need to clone/fork the repo, do npm init, add dependencies, debug, etc. Lots of stuff that can't be covered in a single answer.

Meteor: Cannot find module 'angular'

I'm newbie on Meteor.
After one week on it, and started by implementing the todo of the tutorial as describe here, every things was good locally.
just the fact that I'm continually trying to deploy it, but my heroku
link(https://tasktor.herokuapp.com) just show a blank page with
the this error in de debugger:
Error: angular#^1.2.27 not installed. tmeasday_check-npm-versions.js:66:11
Error: Cannot find module 'angular'
Note that everything is clean on http://localhost:3000.
Already try a lot of solutions, as:
meteor add angular
meteor npm install --save angular
Disable minification of Js and Css.
This is the repository of this app deployed to heroku: https://github.com/dassiorleando/tasktor
his buildpack: https://github.com/dassiorleando/heroku-buildpack-meteor,
it is a buildpack with an updated Node Engine(4.5.0), that allowed to run an app with the meteor 1.4.X version.
Knowing that I add Angular-Material after finish this tutorial, because I wanted to have a clean material design style on my todo. You can check the repository to look about.
How can I handle this situation ?
Thanks in advance.
Doing this:
meteor add angular
Adds an old atmosphere angular-meteor package, which also refers to an old (1.2.27) version of angular. The best way to proceed is to remove this and just use angular npm packages. You will need these packages
pbastowski:angular-babel
urigo:static-templates
dotansimha:accounts-ui-angular
The last one is if you are using the accounts package.
The tutorial at https://www.angular-meteor.com/tutorials/socially/angular1/bootstrapping recommends this:
So let's remove it by running:
$ meteor remove blaze-html-templates
$ meteor remove ecmascript
Now let's add the Angular 1 package to Meteor, back in the command
line, launch this command:
$ meteor npm install --save angular angular-meteor babel-runtime
$ meteor add angular-templates pbastowski:angular-babel
That's it! Now we can use Angular 1's power in our Meteor app.

Heroku missing module

I'm trying to deploy a simple node.js server to Heroku, but keep running into this error:
Error: Cannot find module 'morgan'
I'm using morgan to do some HTTP logging, i have morgan in my package.json under the devDependencies (along with many others)
"devDependencies": {
"morgan": "~1.5.0"
}
I can do npm install locally and start the server without any issues, but when I deploy to Heroku I keep running into that error once it starts the server.
Is there anything I'm forgetting?
By default Heroku execute npm install --production which avoid install devDependencies, quoting literally documentation of Heroku.
The Heroku node buildpack runs npm install --production, which doesn’t install devDependencies in your package.json file. If you wish to install development dependencies when deploying to Heroku, you should move your build dependencies (such as grunt plugins) from devDependencies to dependencies in package.json.
If you use the Morgan module, you need move it to 'dependencies'.
Source: https://devcenter.heroku.com/articles/nodejs-support

Resources