Log file (not found) / Heroku - node.js

While debugging an app on Heroku, I get this kind of message in the log console:
............
app[web.1]:
app[web.1]: npm ERR! A complete log of this run can be found in:
app[web.1]: npm ERR! /app/.npm/_logs/2017-08-19T03_00_34_428Z-debug.log
heroku[web.1]: Process exited with status 1
My problem is that I don't know how to find this file:
/app/.npm/_logs/2017-08-19T03_00_34_428Z-debug.log
The given path taken as is, is obviously wrong and wherever I look I do not see it.
Anyone knows where the file is?

I have the same question. Not able to find this log file.
However, you can view the log by setting it to verbose
heroku config:set NPM_CONFIG_LOGLEVEL=verbose
and then running git push heroku master

Related

Puppeteer and nodejs throws error with Heroku

I created an app and ran it on my localhost which worked perfectly fine.
Then tried to deploy on Heroku, added Puppeteer Heroku and nodejs build pack.
Added the following args to the puppeteer launch function:
const browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox"],
});
also deployed with:
$ git add .
$ git commit -m "First commit"
$ git push heroku main
So far so good, no problems during deployment.
But when I open up the application, I just see that:
and get following errors in the logs:
2022-10-17T18:44:50.357107+00:00 heroku[web.1]: Starting process with command `npm start`
2022-10-17T18:44:52.117360+00:00 app[web.1]:
2022-10-17T18:44:52.117423+00:00 app[web.1]: > fetch-data#1.0.0 start
2022-10-17T18:44:52.117426+00:00 app[web.1]: > node server.js
2022-10-17T18:44:52.117429+00:00 app[web.1]:
2022-10-17T18:44:52.439078+00:00 app[web.1]: Listening on port 41022...
2022-10-17T18:44:52.441949+00:00 app[web.1]: /app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:69
2022-10-17T18:44:52.441949+00:00 app[web.1]: throw new Error(missingText);
2022-10-17T18:44:52.441949+00:00 app[web.1]: ^
2022-10-17T18:44:52.441950+00:00 app[web.1]:
2022-10-17T18:44:52.441951+00:00 app[web.1]: Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (1045629).
2022-10-17T18:44:52.441951+00:00 app[web.1]: at ChromeLauncher.launch (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:69:23)
2022-10-17T18:44:52.441951+00:00 app[web.1]: at async start (/app/bot.js:13:19)
As I can see he is trying to get to "/app/node_modules/puppeteer-core/.." which would be the wrong I assume?
Anyone who can help me out or prefer something else?
Thanks in advance!

MERN deployment to Heroku

I'm having a really hard time figuring out how to deploy my app to heroku. Im new to all of this so I've tried different ways and following different tutorials but I just can't seem to find out how to do it.
This is my github repo:
https://github.com/solecity/card-deck-manager-app/tree/main
And in my logs from heroku I'm getting different errors:
2021-07-14T12:22:33.592361+00:00 app[web.1]: npm ERR! missing script: start
Starting process with command `node index.js`
2021-07-14T12:25:08.838023+00:00 app[web.1]: internal/modules/cjs/loader.js:905
2021-07-14T12:25:08.838048+00:00 app[web.1]: throw err;
2021-07-14T12:25:08.838048+00:00 app[web.1]: ^
2021-07-14T12:25:08.838049+00:00 app[web.1]:
2021-07-14T12:25:08.838049+00:00 app[web.1]: Error: Cannot find module '/app/index.js'
2021-07-14T12:27:16.812794+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'express' imported from /app/server/index.js
If anyone could shed some light on how I can fix this it will be greatly appreciated
as the error states, you need to provide a start script in your package.json
apparently this is what heroku tries to runs. (error 1)
And if it doesn't find it, it runs something like node index.js (error 2)
also, you have not registered express in your dependencies in the main package.json so heroku doesn't install it. (error 3)
I'm not very used to heroku, but i think you should create 2 separate projects, and register them separately in heroku. that way he would find onlythe appropriate package.json and run.

How to increase NodeJS heap (--max-old-space-size) in Bitbucket Pipelines for Typescript/Webpack?

I am running into memory issues during the webpack packaging step in a serverless/TypeScript project.
I have tried:
'increase-memory-limit' npm package to no avail
Calling the following command from an npm run script
Calling the following command directly through bitbucket-pipelines.yml.
node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy
It works fine locally with this command, but in Bitbucket pipelines I get the following output:
Serverless: Bundling with Webpack...
internal/child_process.js:323
throw errnoException(err, 'spawn');
^
Error: spawn ENOMEM
at _errnoException (util.js:1022:11)
at ChildProcess.spawn (internal/child_process.js:323:11)
at exports.spawn (child_process.js:502:9)
at Object.exports.fork (child_process.js:103:10)
at fork (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/fork.js:17:36)
at Farm.startChild (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:106:16)
at Farm.processQueue (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:279:10)
at Farm.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/farm.js:97:21)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! platform-state-machine-import#0.0.2 deploy: `node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy "--stage" "feattsify" "--region" "us-east-1"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the platform-state-machine-import#0.0.2 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-02-07T22_37_25_150Z-debug.log
I've done a lot of googling and searching here to try to find if Bitbucket has some kind of env. variable you can set for runtime args, etc., but can't seem to find anything that doesn't tie back into the aforementioned NPM package.
I encountered a similar issue some time ago in some Jenkins build tasks.
You might be able to solve it using the NODE_OPTION environment variable:
NODE_OPTIONS=--max_old_space_size=4096
From your error stacktrace, it looks like new node processes are beeing spawned.
If you can set this environment variable, it will be used by node to pass arguments to any new processes, and so to the spawned processes that run out of memory here.
https://nodejs.org/dist/latest-v8.x/docs/api/cli.html#cli_node_options_options
Defining a fixed amouth of memory could be tricky, since you will not use the full memory available on the runner machine.
I wrote a code, to get the total memory on the runner machine, deduct 400mb (to other server resources), and assign it as node memory limit.
FREE=$(free -m);
echo "FREE: ${FREE}"
FREE_FINAL=$(echo "$FREE" | grep -F Mem: | grep -o "[0-9]*" | grep -o -m1 "^[0-9]*")
echo "FREE_FINAL: ${FREE_FINAL}"
MEM_LIMIT=$(($FREE_FINAL-400))
echo "MEM_LIMIT: ${MEM_LIMIT}"
echo " - "
export MEMORY_LIMIT="${MEM_LIMIT:=3500}";
export NODE_OPTIONS="--max-old-space-size=${MEMORY_LIMIT}"
echo "NODE_OPTIONS: ${NODE_OPTIONS}"
You can adapt to your case and use the maximum memory to your script, but respect the limit as well.
If you use docker, it can be added to an entrypoint.sh file (that will run on build time, but on each docker start as well).
Increase it from your start command e.g
node --max-old-space-size=8192 server.js
There ended up being two workarounds for this issue. The ENOMEM error was appearing first because I needed more memory for the Node process, and second because the memory I was allotting to the Node process exceeded that which was available in the Bitbucket environment (default 4gb).
Option 1:
Using any of the other answers' options AND ensuring the Bitbucket pipeline environment has enough memory - for me, that meant cranking the size to 2x (see this link).
Option 2:
Adding the 'transpileOnly' flag to your webpack.config.js file, using ts-loader as your transpiler. This skips type-checking and saves memory at package/deploy time. WARNING: You still should type-check your project on build. For me, this meant running tsc before packaging/deploying.
rules: [
// all files with a `.ts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
transpileOnly: true
}
},
],

Heroku Deploy Error: Cannot find module '/app/index.js'

I' m trying to deploy mt app on Heroku but I always get the same error:
2016-08-18T10:16:10.988982+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-08-18T10:16:13.180369+00:00 app[web.1]: module.js:341
2016-08-18T10:16:13.180389+00:00 app[web.1]: throw err;
2016-08-18T10:16:13.180390+00:00 app[web.1]: ^
2016-08-18T10:16:13.180391+00:00 app[web.1]:
2016-08-18T10:16:13.180392+00:00 app[web.1]: Error: Cannot find module '/app/index.js'
2016-08-18T10:16:13.180393+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:339:15)
2016-08-18T10:16:13.180394+00:00 app[web.1]: at Function.Module._load (module.js:290:25)
2016-08-18T10:16:13.180394+00:00 app[web.1]: at Function.Module.runMain (module.js:447:10)
2016-08-18T10:16:13.180399+00:00 app[web.1]: at node.js:405:3
2016-08-18T10:16:13.271966+00:00 heroku[web.1]: Process exited with status 1
2016-08-18T10:16:13.273383+00:00 heroku[web.1]: State changed from starting to crashed
As I read in similar requests I have already added a Procfile containing the following code: web: node index.js, but I still have same issue.
Anybody have any idea where the problem is? Any guidance would be greatly appreciated.
Thank you in advance!
Is your index.js file in your root directory?
web: node ./index.js
Your file might be nested like so app/src/index.js
web: node ./src/index.js
Does your index.js have an uppercase 'I'? It has to be index.js and not Index.js
If you do have your index.js file at the root of your project, but heroku's error says that the module cannot be found. Then, the problem you are having might be due to GIT.
How can we make sure this is the case?
Well, your git repo might not be adding your index.js file to commits nor pushing it to heroku. You can verify this by looking at the files that git is watching in your local repo with the following command:
git ls-files
Your index.js file should be listed. If not, then your file is being ignored.
Solution: Force add your file.
git add --force ./index.js
Now you can commit and push to heroku and you should be up and running.
This might also be the case when having your index file inside a dist directory or src (app/dist/index.js or app/src/index.js).
Add relative path for index.js file as bellow
web: node ./index.js
I am getting this error also. then I solve it by fixing importing file. My folder was was in lowercase like the product, and I import it like Product. It doesn't give me errors in localhost. Please check if the import files path is right in the index file.
My issue was a fault with my local development environment. Somehow...JavaScript code was being injected into my app project, which I didn't do.
Not knowing this was occurring, Heroku started seeing errors during my push, like "can't find jQuery, even though your using it in your app". I was like "what????, I'm not even using jQuery." I then re-opened a .js file in my project...and there it was, a const variable declaring jquery. So I say all that say, check your VSCode extensions, your third party npm packages, and everything for that matter to make sure things like this are not happening to you.
If error still happening, try using this:
web: node .
Go to your package.json file in root directory of any sub directory with another instance.
Change the script tag from "start": "node start" to "start": "node app.js".
Please note: in my case my main file is app.js yours can be index.js or server.js or anything you named it.
it can also happen if you give space in folders name or create your files in multiple folders then it will work in localhost but in server it will give you application error so don't make multiple folders and as well as don't give space in them and specify path correctly then it will work fine.

Openshift - 503 Service Temporarily Unavailable when i am accessing the app

I got an app hosted on Openshift here , using node.js and mongo db. It was running perfectly yesterday and today when i am accessing the same, i am getting
Service Temporarily Unavailable Error
I searched some threads and tried this command
rhc tail -a news
and result was
npm ERR! node -v v0.6.20 npm ERR! npm -v 1.1.37 npm ERR! code
ELIFECYCLE npm ERR! message OpenShift-Sample-App#1.0.0 start: `node
server.jsnpm ERR! messagesh "-c" "node server.js"` failed with 1
npm ERR! npm ERR! Additional logging details can be found in: npm ERR!
/var/lib/openshift/4eb0c449f78a4d7e937726185b5e636e/app-root/runtime/repo/npm-debug.log
npm ERR! not ok code undefined npm ERR! not ok code 1
I have also tried
rhc app status -a news
and result was
RESULT: Geargroup nodejs-0.6+mongodb-2.2 is started
also i tried to restart my app
rhc app restart
and it restarted properly.
Could you suggest me what is the issue.?
As mentioned by Hardy, i still dont know which resource got exceeded. But have fixed it now.
Here is what i did.
just get remote access to your app console as described here.
ssh into the console with a client like PuTTy or Cygwin.
just check the status of your app by typing ctl_app status. for me it came like :
App is currently inaccessible or stopped.
just start it by typing ctl_all start
Now app is working as previously.
Are you using a free OpenShift account (free grear)? If so, what is your app doing? Is it very CPU or memory intensive. Your gears are monitored using cgroups and once you exceed any resource limit (cpu, memory, threads) your app gets killed. In this case you would get the message you describe. Unfortunately there is no way of telling which resource you exceeded and you don't get a notification that this was the problem. At least that is something I experienced with my apps. Of course there could be other problems with your app.

Resources