Heroku gives me errors suddenly,
It worked fine for about a month with same settings, yesterday after editing some minor things in the project and uploading to git it gave me error when pushing to heroku master:
Creating an optimized production build...
Failed to compile.
./src/sections/welcome/welcome.css
Error: Didn't get a result from child compiler
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ghvinieri#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ghvinieri#0.1.0 build 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! /tmp/npmcache.KO8no/_logs/2019-03-20T10_43_07_497Z-debug.log
-----> Change to Node.js build process
Heroku has begun executing the "build" script defined in package.json
during Node.js builds.
Read more: https://devcenter.heroku.com/changelog-items/1573
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
I tried putting node version in package.json, deleting package.json, node_modules are included in gitigonre, even tried to copy repo from heroku master which contained older code that works on heroku right now, then editing it and uploading; it still gives error, it makes no sense to me. it works on heroku right now with the same settings though when I upload with a minor change it gives errors. could anyone help me with this? Im stuck, looked up all possible solutions none of them work.
Related
I built my application using create-react-app and created the backend using node.js and express..i used the build command to get a production version of the react app and made it work with my backend and everything was working fine on localhost ..this is how my file structure look like:
when i try to deploy it to heroku the build fails giving me this error
Could not find a required file.
Name: index.html
Searched in: /tmp/build_839c6cd8/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! proj#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the proj#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Some possible problems:
- Node version not specified in package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
why is the build failing? what am i doing wrong?
EDIT: does heroku require a certain file structure or something? it seems that it can't handle the "build" folder..i created a public dir in my project's root (outside build) and moved my index.html to it and this solved the problem for THIS file..now when i try to deploy it says
Could not find a required file.
Name: index.js
..so the file that's "missing" now is the js file..what should i do now? create a new src dir and move my js to it? this is some nonsense..what's going on?
uhh "fixed?"..seems heroku was trying to run the build script from create-react-app by itself instead of just running my project files as they are..i had to remove the create-react-app scripts from the package.json file and now everything works as intended.. although i don't understand why did that happen, if anyone with heroku background can explain that it would be great..
tl;dr: solution is to remove the create-react-app scripts from package.json
I have been coding a bot using discord.js, visual studio code, and node.js, and I have been trying to host it on Heroku. However, the log in my Heroku project claim that my build is failing, and it is giving the following message when I view the build log of the failure:
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> #discordjs/opus#0.5.0 install /tmp/build_0229f43f/node_modules/#discordjs/opus
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! #discordjs/opus#0.5.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the #discordjs/opus#0.5.0 install 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! /tmp/npmcache.q9Do7/_logs/2021-04-19T19_49_08_993Z-debug.log
-----> Build failed
Also, the more recent changes that I have made to my bot, like adding aliases to commands and changing the ping of my announce command, don't apply when I run the bot off of Heroku, but do work when I run the bot locally, and I think that the build failure may be the reason behind this. I may be wrong, but I am still relatively new to coding Discord bots. How can I fix the build failure?
I've been searching for a solution to this problem all day.
I finally found it:
While hosting your bot on heroku you can use "discord-music-player" instead of #discordjs/opus or opusscript. Tell me if it worked for you!
#discordjs/opus is not allowed on Heroku afaik.
Use opusscript instead if you really need to use music.
But as devs mentioned, #discordjs/opus is much better peformance wise so I recommend searching for another hosting solution if you want the audio streaming functionalities.
Prebuild detected (node_modules already exists) you need to hide your node_modules using .gitignore in your folder project
I have a Node.js app running as an Azure Website and doing my deployments using Git. The app requires a module that's private (i.e. written by me, no relevance to anyone else and thus not available in NPM) and common to my other projects. Let's say the module is located in ./lib/mymodule and it has its own dependencies in its package.json file. The problem is I cannot figure out how to have Azure install the dependencies of my own module. I would like to avoid having to add my node_modules directory under version control (currently .gitignor'd) or having to add the module's dependencies as my app's dependencies (which is ugly and a bit inconvenient).
It's trivial to get this working on my local dev environment. The first thing I did was simply include my own module as a local dependency in my package.json as described in https://docs.npmjs.com/files/package.json (see section "Local Paths"). A simple npm install would now install my own module nice and easy. Since I know that Azure runs npm install every time I deploy a new version, I figured this is all I need. Turns out I was wrong: local paths in package.json dependencies section were only introduced in NPM 2.0.0 and Azure is running NPM 1.4.x, so the deployment obviously failed. Ok then, can I run a different version of NPM in Azure? In theory, yes, but practice seems to be something else. I tried out https://github.com/glennblock/azure-node-runtime-selector but to no avail. Here's some of the deployment output:
remote: Handling node.js deployment.
remote: KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
remote: ............
remote: node version: 0.11.14
remote: ..............
remote: 2.1.18
remote: npm version: 1.4.6
remote: An error has occured during web site deployment.
remote: npm failed
remote:
remote: Error - Changes committed to remote repository but deployment to website failed.
Apparently it fails to install any NPM version >= 2.0.0.
Ok then, this is not so bad, I figured. I can work with an older version of NPM, I just need to run another npm install to install my own module, as NPM documentation hints. So I took the local dependency away from my package.json and simply run npm install ./lib/mymodule. Nice and easy... on my local. I dug up instructions how to run custom commands on deployment in Azure: just run azure site deploymentscript --node and edit deploy.sh it creates. Just to ensure the custom deployment script works at all, I made one deployment without editing anything. Worked ok. Then I added a line in deploy.sh (around line 111):
# 3. Install npm packages
if [ -e "$DEPLOYMENT_TARGET/package.json" ]; then
cd "$DEPLOYMENT_TARGET"
eval $NPM_CMD install --production
eval $NPM_CMD install ./lib/mymodule #This line added by me
exitWithMessageOnError "npm failed"
cd - > /dev/null
fi
Nope. This is what I get:
remote: Installing npm packages...
remote: npm ERR! addLocal Could not install ./lib/mymodule
remote: An error has occurred during web site deployment.
remote: npm ERR! Error: ENOENT, stat 'd:\home\site\wwwroot\lib\mymodule'
remote: npm failed
...snip...
remote:
remote: npm ERR! System Windows_NT 6.2.9200
remote: npm ERR! command "d:\\Program Files (x86)\\nodejs\\0.10.28\\node.exe" "D:\\Program Files(x86)\\npm\\1.4.9\\node_modules\\npm\\bin\\npm-cli.js" "install" "./lib/mymodule"
remote: npm ERR! cwd d:\home\site\wwwroot
remote: npm ERR! node -v v0.10.28
remote: npm ERR! npm -v 1.4.9
remote: npm ERR! path d:\home\site\wwwroot\lib\mymodule
remote: npm ERR! code ENOENT
remote: npm ERR! errno 34
remote: npm
remote:
remote: Error - Changes committed to remote repository but deployment to website failed.
This is where I got stuck. I tried playing around with the path, guessing that Windows is mangling it somehow, but haven't found a working solution yet. The weird thing is that ./lib/mymodule would seem to resolve to d:\home\site\wwwroot\lib\mymodule which look just fine to me and DOES exist, at least after deployment when I FTP'd in to take a look.
I would appreciate any and all help in either getting NPM 2.x.x working or my making custom deployment go through. Or maybe there's an alternative to managing my local modules I haven't thought of? And if all else fails, maybe I'll just commit my node_modules or manage my dependencies manually. I've already used way too much time to resolve what first seemed like a trivial issue. :)
Azure WebSites team will be shipping support for npm 2.1.17 out-of-the box by end of the month (Jan'15). Hope this will help you unblock you.
Having followed the 12devs of Xmas tutorial to create my first Node.js app (http://12devsofxmas.co.uk/post/2012-12-28-day-3-realtime-collaborative-drawing-with-nodejs) I'm now attempting to follow Rob Dodson's tutorial for deploying it through Heroku (http://robdodson.me/blog/2012/06/04/deploying-your-first-node-dot-js-and-socket-dot-io-app-to-heroku/)
However, after committing to github, when I attempt to push to Heroku, I get the following error output:
-----> Installing dependencies with npm
npm WARN package.json Draw#0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/express
npm http 200 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-2.5.11.tgz
npm http 200 https://registry.npmjs.org/express/-/express-2.5.11.tgz
npm ERR! Refusing to delete: /tmp/build_1t6d7hbd2psal/node_modules/.bin/express not in /tmp/build_1t6d7hbd2psal/node_modules/express
File exists: /tmp/build_1t6d7hbd2psal/node_modules/.bin/express
Move it away, and try again.
npm ERR! System Linux 2.6.32-350-ec2
npm ERR! command "/tmp/node-node-Fenl/bin/node" "/tmp/node-npm-6pyT/cli.js" "install" "--production"
npm ERR! cwd /tmp/build_1t6d7hbd2psal
npm ERR! node -v v0.6.20
npm ERR! npm -v 1.1.65
npm ERR! path /tmp/build_1t6d7hbd2psal/node_modules/.bin/express
npm ERR! code EEXIST
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_1t6d7hbd2psal/npm-debug.log
npm ERR! not ok code undefined
npm ERR! not ok code 1
! Failed to install --production dependencies with npm
! Heroku push rejected, failed to compile Node.js app
To git#heroku.com:secure-dawn-2437.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:secure-dawn-2437.git'
My package.json file is as follows:
{
"name": "Draw",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "~2.x",
"socket.io": "~0.9.x"
},
"engines": {
"node": "0.6.x",
"npm": "1.1.x"
}
}
I'm sorry - I'm totally new to this sort of development, having mostly worked in Java while in school, but I'm anxious to learn. I assume the problem is somehow with express, but I'm not sure what it means by "move it away, and try again."
Do you have a Procfile file in your application you are trying to deploy?
If not, look at the documentation available on Heroku's Website:
https://devcenter.heroku.com/articles/nodejs#declare-process-types-with-procfile
EDIT:
I highly suggest you to deploy a really simple Node.js application at first (like a Hello World), just so you can trace back the source of your error.
Try removing bin and .bin from your .gitignore or adding node_modules to .gitignore. More info here: Fail to deploy node.js application to heroku
I was able to solve this by temporarily disabling Heroku's use of cache:
heroku config:set NODE_MODULES_CACHE=false
Push the build, then turn cache back on.
I'm having an issue deploying a restify application to Heroku.
npm ERR! dtrace-provider#0.0.9 install: `node-waf clean ; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean ; node-waf configure build"` failed with 1
npm ERR!
npm ERR! Failed at the dtrace-provider#0.0.9 install script.
npm ERR! This is most likely a problem with the dtrace-provider package,
npm ERR! not with npm itself.
It seems as if Heroku has an issue with dtrace, which restify makes use of, although doesn't require, I've read that you can bypass this by removing dtrace from restify's package.json file, however I have attempted this with no success.
I'm new to node and using Heroku and git so I'm sure there's something I'm missing, restify's package.json file contains the following:
"dependencies": {
"dtrace-provider": "0.0.9",
},
"optionalDependencies": {
"dtrace-provider": "0.0.9"
},
I have removed these lines but still receive the same error message as above after committing to git and pushing to Heroku.
Can anyone see what I'm missing?
When you deploy your application on heroku it installs the dependencies based on your application package.json file so it does not matter if you remove it from restify's package.json file because heroku picks the restify's package.json file from it's repository not from your repository. So, you need to find out how to resolve this error.