Error deploying node js restify application to heroku - node.js

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.

Related

MERN app Heroku build failed "Could not find a required file. Name: index.html"

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

npx start, npx install npx init is not working

I have been working with react for years using NPX and yarn and I just got assign to built an app with react-native using react native-cli so i tried setting up my environment using the react native docs and some YouTube videos. But after following the instructions like downloading android studios and adding in my new environment variable, I'm getting an error every time i tired to run
"npx react-native init AwesomeProject" which gave me this error
[![npx react-native init result][1]][1]
I also tried npm install and i got this error on git bash and also on my commandline
npm ERR! syscall spawn bash
npm ERR! path C:\Users\Dennis\Desktop\GitHub\LCRN01-travel-onboarding-app-master\LCRN01-travel-onboarding-app-master\node_modules\core-js
npm ERR! errno -4058
npm ERR! enoent spawn bash ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dennis\AppData\Local\npm-cache\_logs\2021-11-13T05_50_35_592Z-debug.log```
and also npx react-native start is showing this error on git bash
```openssl config failed: error:02001003:system library:fopen:No such process
Command `start` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project.```
I have tried running "npm cache clean --force"
but still nothing changed
I can't even run npx create-react-app anymore because i keep getting this error
npx creat-react-app test
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/creat-react-app - Not found
npm ERR! 404
npm ERR! 404 'creat-react-app#latest' is not in this registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Dennis\AppData\Local\npm-cache_logs\2021-11-13T06_05_46_068Z-debug.log
I'm currently using a windows 10 device
node -v 16.13.0
npm -v 8.1.3
[1]: https://i.stack.imgur.com/OTLYj.png
It's create-react-app.
Not totally sure but another issue could be that your Git bash isn't in your PATH.
Plus, npx start and npx install doesn't sound right, maybe you meant npm start and npm install.
On top of that, it seems you have node v11 and not node v16, maybe you have different versions of node, some in Windows' PATH and some only accessible from bash.
It could help to clean up and reinstall your node versions and Git bash, also check your environment variables for remnants of previous versions, and make sure to not confuse npm and npx.

Heroku failed to push

I want to deploy my project on Heroku but when I do it, I have this error :
npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR!
npm ERR!
npm ERR! Invalid: lock file's fs#0.0.1-security does not satisfy fs#*
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.3oo5n/_logs/2021-11-25T14_47_03_365Z-debug.log
-----> Build failed
Even when I delete "package-lock.json" and make "npm install", it still doesn't work.
This is the first time that I have this problem with Heroku deployment, I don't know what can I do about it.
Thank you for your help.
I was having the same issue and it was working at first then it stopped. Deleting the packages-lock.json file and then re-running npm install wasn't working. Strangely it did work if I just removed packages-lock.json but that wasn't the ideal solution.
Finally, I did get it to work by following:
delete my packages-lock.json file
delete node_modules
re-run npm install

Trouble with first Node app deployment through Heroku

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.

Fail to deploy node.js application to heroku

I am trying to deploy a simple node.js express-based application to heroku, something which is apparently very basic: https://devcenter.heroku.com/articles/nodejs
Here is my package.json:
{
"name": "cours-lic3-blois",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "*",
"ejs": "*",
"github-flavored-markdown": "*",
"less-middleware": "*"
},
"engines": {
"node": "0.8.8",
"npm": "1.1.65"
}
}
When I git push heroku master I got the following trace:
-----> Heroku receiving push
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.8.8
Using npm version: 1.1.65
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm ERR! Error: ENOENT, chmod '/tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 2.6.32-348-ec2
npm ERR! command "/tmp/node-node-tonf/bin/node" "/tmp/node-npm-NG88/cli.js" "rebuild"
npm ERR! cwd /tmp/build_1suuxlhd9s8n6
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.65
npm ERR! path /tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_1suuxlhd9s8n6/npm-debug.log
npm ERR! not ok code 0
! Failed to rebuild dependencies with npm
! Heroku push rejected, failed to compile Node.js app
To git#heroku.com:fast-everglades-2007.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:fast-everglades-2007.git'
I tried to tweak various versions in my package.json but to no avail. I am developing on windows and it might be possible this ENOENT issue is due to some filemode issue.
I got this fixed by:
Making sure Procfile is committed into git
Removing the node_modules/ folder and committing that into git (git rm -r node_modules/)
Afterwards, I did the git push heroku master then the error disappeared.
I had this problem, and it was because:
I keep node_modules in version control
I had bin in my .gitignore file
npm was attempting to chmod express/bin/express, but due to my .gitignore this file wasn't in git and thus was not being cloned during the deploy, so it failed. I didn't notice it because a local npm install would create the bin/express file as usual.
Removing bin from .gitignore and committing the missing files solved the problem for me.
Heroku team, could you please consider configuring npm to use npm install --no-bin-links --production by default, or creating an environment variable to let users set that flag. This is a serious bug in node installs. Removing the bin directory from my .gitignore (as suggested below) enabled me to deploy, but it breaks using git effectively in a cross-platform development environment, requiring an explicit npm rebuild on every git pull where node_modules might have changed.
NPM best practice is to avoid having node_modules in .gitignore (see http://www.futurealoof.com/posts/nodemodules-in-git.html ).
I believe --no-bin-links will provide the best of both worlds, enabling deploys of node_modules where the bin directory has been excluded, supporting npm rebuild, but not failing when a bin link is created.
I submitted a pull request here: https://github.com/heroku/heroku-buildpack-nodejs/pull/33
Thanks!
similar issue was fixed by renaming gruntfile.js to Gruntfile.js
I had a similar problem a few days ago, I think it was because I imported a module created by me and that was what gave the error;
I corrected it like this:
I called the module "path"
const path = require ("path")
and then where my module was imported I made a join of the file path
const myModule = require (path.join (__ dirname, 'MyModule.js'))

Resources