I am trying to deploy my node-express website on heroku. Everything works fine, but just one problem.
I have used express-stormpath as a dependency in my project, which i have customized(the views only).
When I deploy this to heroku, using git push heroku master, the node_module is ignored while uploading and all the modules are installed by heroku itself using npm. So my customization to the node module is not reflected at heroku.
I have tried this also: npm install private github repositories by dependency in package.json
Any suggestions on how to upload whole project including the node_modules to heroku?
If you're using express-stormpath, you should not be customizing the views inside of node_modules -- this is the wrong way to do it. Instead you should be putting your custom views inside of your own 'views' folder, and telling express-stormpath where that file is.
Here's an example of a custom login view, for instance:
app.use(stormpath.init(app, {
loginView: __dirname + '/views/login.jade',
// ...
}));
If you take a look at the express-stormpath docs here: https://docs.stormpath.com/nodejs/express/product.html#update-template-paths (it shows you how to do this).
NOTE: I'm the author of express-stormpath and I randomly saw this question ^^ Hope this was helpful!
Related
I'm a newbie to deployment and having lots of issues and could really use some guidance! I have an app with the folder structure shown below.
When I started the deployment, I got the backend part to deploy. Screenshot attached
I did a npm build in my client folder and have the following added to the script in my backend package.json
However, when I try to then deal with including the client side, I have a problem and am getting this error.
I was following a tutorial that had a similar folder structure and deployed via
git subtree push --prefix backend heroku master
I also tried 'main' based on answers on stack overflow but it didn't change the error. I am the only one doing anything with this repository (and it's currently private), have no other branches, and I have nothing that hasn't been pushed to my repository in Github (no changes made recently) so I'm not sure what this is about. Any ideas???
I think your folder structure could be the error.
Try something like that:
projectName:
-client
-package.json
-.env
-index.js
with your project structure, Heroku can't read the index.js and the package.json. Because it is nested in your backend folder.
I think this is why you are getting this error:
Error: Cannot find module '/app/backend/server.js'
We have a node web project hosted off of Heroku that contains a library hosted on GitHub. We often make changes to the GitHub library.
When we push the updated node web project to Heroku for deployment, it doesn't check if the library on GitHub has been updated.
We're wondering if there is a command that clears the cache/node_modules folder on Heroku to resolve this?
Cheers,
Peter
I found the solution after searching for a while. You have to disable the cache via config and also purge the existing one for old builds. Also I recommend deleting the package-lock.json to clear any issues.
https://devcenter.heroku.com/articles/nodejs-support#cache-behavior
https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache
I am trying to deploy a react based app in jetty. As part of that, I thought of trying to do the same in jetty server.
I followed a link:
https://www.megadix.it/blog/create-react-app-servlet/
The above link explains details about it and at the end there is a github project for making a war. the link to that is below:
https://github.com/megadix/create-react-app-servlet
Now, I am able to deploy the war created using the above github project in tomcat 9. I am unable to understand how the dependency resolution of node_modules is happening. Also I am unable to deploy the same war in jetty(putting the war in webapps folder and starting jetty)
Thanks
Single page applications needs to be compiled into one (in same cases more) .js file. In your case, create-react-app or similar tools are responsible for fulfilling this requirement.
In the pom.xml execution list, you can see npm install, npm build commands. They are pretty much similar as mvn clean install and mvn buuild.
Dependencies are resolved from package.json dependencies field and installed under node_modules. Once dependencies are there, npm build (or create-react-app-servlet build), compiles all the source code + dependencies into a js file. This probably has a name like main.XXXXXX.js.
In the end, you have a dist folder consisting of .html, .js and other resources.
It'd be better if you share more details of what's happening with jetty deployment
Perhaps this is a silly question. It came out while I was learning how to set up a Node.js application for production on Ubuntu and digital ocean.
Let's say I have a simple data visualization app made in Node.js, using node modules such as express, page, axios, yo-yo, and browserify to compile my files.
I want to upload my app to a webhost that already exists.
This is the structure's app:
node_modules
public (app.js and app.css)
src (header, home, and footer folders)
views (index.pug file)
gulpfile.js
index.scss
package.json
server.js
Which files I need to upload in order to see my app as I see it in localhost?
You need to upload everything.
What Maximelian says is true if you're going to run npm install again on your server. The standard way of doing this is sync the project using git (you can find a .gitignore template for node.js here).
Once setup you'd do something like this on the server after making the commit locally, and pushing to your remote git repo:
git pull
npm install
npm start
If you were to just ftp the full working project including node_modules it would work just by running npm start. But the above method is what I'd recommend.
If I remember correctly everything except node_modules, if you did not customized them. (rewrite some behavior after module installation)
I'm working on my node.js demo.location.io web app at the same time as my location.io library. I'd like to be able to make changes to the location.io library and push them up to github from inside the node_modules folder. Is there any support for this in npm?
(If I understand your question) You can use
npm link
to link your location.io to your local demo.location.io repo. More info here