How to deploy a heroku app containing a forked github repo - node.js

I have a Node app that is running on heroku.
Now I want to make some changes to the package react-window that I'm using (the first time that I'm trying this)
So I forked the react-window repo and replaced the original packgage using:
yarn remove react-window
yarn add https://github.com/myusername/react-window.git
When I build this on my local machine, everything is fine and the forked packages is used.
But when I try to deploy it on heroku the build fails and I get this error:
error https://registry.yarnpkg.com/#babel/runtime/-/runtime-7.0.0.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, chmod '/tmp/yarncache.wxh1C/v4/npm-#babel-runtime-7.0.0-adeb78fedfc855aa05bc041640f3f6f98e85424c/node_modules/#babel/runtime/helpers/asyncIterator.js'"
I tried to point to a specific branch, but this also does not work:
yarn add https://github.com/myusername/react-window.git#master
When I reinstall the original package, everything is fine again.
So my question: what is the right way to add a forked package when deploying to heroku?

Related

Deploying next app to Azure fails because node_modules need to be re-installed

I'm creating a build in Azure pipelines and copying node_modules as well as 'out' folder, package.json, package-lock.json, next.config.js and .next folder. I copy all of these into an artifact directory.
I then zip this as an artifact and then do a zip deploy to Azure App Service Linux Web app.
However running npm start (which just points to next start in the package.json) doesn't work as it complains about next not being found in node_modules (even though its there)
What do I need to do to get it work?
If I download the zip file and unzip it locally, it doesn't work either even though all the node_modules are there. I need to run npm ci to be able to get next start to work. How come?
Aren't I meant to just be able to copy node_modules across and everything should just work?
Also bonus points - do I need to force next to start on port 8080 on azure? The default port 3000 doesn't seem to work?
And Azure docs say that npm install is run when package.json is detected. However that's clearly not happening either.
Any help and insights would be most appreciated!
If anyone is trying to deploy Next.js SSR apps to Azure Web apps, the issue is the copying of the node_modules and the config of next.config.js
I was using the File Copy task in my yml file. This isn't good enough.
You have to use cp -paR node_modules to your artifact folder.
We don't have a server.js file but you can't use serverless unless you create a server.js file :) So I changed the next.config.js to server and then it all works without a server.js file.

React : ENOENT Error while trying to pulish on git pages

I've been trying to post my web app on Github pages but while building the app using the npm run deploy command this error keeps on popping. I'm new to react and can't seem to find what the problem is.the git path is added in env variables. I'm on windows. this is the snapshot of the error.
the deploy script
Try using npm run build and follow the instructions, after that a new folder will be created inside the root folder of your project, and that folder is a compression of your project, and the one you need to deploy on Github.

How to deploy a node.js application to heroku that lies within a subfolder of a repository

I'm unsure how to deploy my web application to heroku where the actual web application is generated within a sub folder. I have the project tree:
app
assets
dist
server
// other stuff ....
now when I want to run my server & frontend, I do gulp. gulp creates a folder named build which contains all needed files for running the web app, so my file tree would become
app
assets
dist
server
build
// other stuff ....
Is there a way to initialize the heroku repository to only the folder build? Since my actual web app lies inside just that folder, it's probably easier for me to only have heroku think the build folder exists.
I currently have heroku setup with only heroku create inside the parent repo
I found a solution to my issue. What I decided to do was include my build folder into my repository (did not add much bloat, only like 50kb). Then, when I wanted to deploy to heroku I did:
git subtree split --prefix build -b deploy
git push heroku deploy:master
git branch -D deploy
this created a branch with only the build folder, pushed that to heroku (use -f if you need to overwrite previous commits), the deleted the deploy branch.
Worked like a charm!

Set up an xcode bot to build and deploy a nodejs express server

I am attempting to set up a xcode project and bot that will build a nodejs application on commit from a github repository and restart the server after the build completes. The bot is currently picking up on the repository changes but fails to build correctly.
I am using a xcode external build tool project that uses /bin/bash as the tool path and the working directory is set to the local repository path.
The bot's after integration script is something like,
npm install --production
npm run build
npm run server:restart
I am getting errors like [npm|node] is not recognized.
Just looking for some clarity to what I might be missing or what could be going wrong.
Add this to the beginning of your script and review the output:
which node
set | grep PATH
This will happen if node is not in your path, which may happen because build scripts have a pretty basic environment - they're not running as a normal user. You may need to add it to your PATH at the start of your build script.

How to deploy a node.js app to heroku?? It is possible or not?

The problem was with git add.I had forgotten to add the node_modules files.I closed the terminal and ran the set of commands given in the Getting started with Heroku and NodeJs[1] again.The application was successfully pushed onto the stack.
Heroku will automatically detect a nodejs application if you include a package.json file in the root of your project. Ensure that package.json is added to your git project before pushing your project to Heroku.
Your nodejs application should be managed with NPM. For a complete working example see the Nodejs guide on Heroku:
https://devcenter.heroku.com/articles/nodejs

Resources