Errors Pushing to Heroku (node.js) - node.js

When I push a default express app to heroku I get the following error. I've ensured I am up to date with heroku-toolbelt etc but it appears to be an error from the heroku side? Has anyone seen this? It pushes alright and works as expected but I suspect this could cause issues in the future.
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 404 bytes, done.
Total 4 (delta 1), reused 0 (delta 0)
-----> Heroku receiving push
-----> Node.js app detected
/app/slug-compiler/buildpacks/nodejs2/vendor/json/json:425
return runInNewContext("(" + JSON.stringify(datum) + ")" + lookupCode);
^
TypeError: Cannot read property 'node' of undefined
at evalmachine.<anonymous>:1:118
at lookupDatum (/app/slug-compiler/buildpacks/nodejs2/vendor/json/json:425:10)
at Socket.<anonymous> (/app/slug-compiler/buildpacks/nodejs2/vendor/json/json:628:24)
at Socket.emit (events.js:61:17)
at Socket._onReadable (net.js:656:51)
at IOWatcher.onReadable [as callback] (net.js:177:10)
/app/slug-compiler/buildpacks/nodejs2/vendor/json/json:425
return runInNewContext("(" + JSON.stringify(datum) + ")" + lookupCode);
^
TypeError: Cannot read property 'npm' of undefined
at evalmachine.<anonymous>:1:118
at lookupDatum (/app/slug-compiler/buildpacks/nodejs2/vendor/json/json:425:10)
at Socket.<anonymous> (/app/slug-compiler/buildpacks/nodejs2/vendor/json/json:628:24)
at Socket.emit (events.js:61:17)
at Socket._onReadable (net.js:656:51)
at IOWatcher.onReadable [as callback] (net.js:177:10)
-----> Resolving engine versions
Using Node.js version: 0.4.7
Using npm version: 1.0.94
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
express#2.5.8 /tmp/build_1m5t2ah1oglfb/node_modules/express
connect#1.8.5 /tmp/build_1m5t2ah1oglfb/node_modules/express/node_modules/connect
qs#0.4.2 /tmp/build_1m5t2ah1oglfb/node_modules/express/node_modules/qs
mime#1.2.4 /tmp/build_1m5t2ah1oglfb/node_modules/express/node_modules/mime
formidable#1.0.9 /tmp/build_1m5t2ah1oglfb/node_modules/express/node_modules/connect/node_modules/formidable
mkdirp#0.3.0 /tmp/build_1m5t2ah1oglfb/node_modules/express/node_modules/mkdirp
jade#0.20.3 /tmp/build_1m5t2ah1oglfb/node_modules/jade
commander#0.5.2 /tmp/build_1m5t2ah1oglfb/node_modules/jade/node_modules/commander
mkdirp#0.3.0 /tmp/build_1m5t2ah1oglfb/node_modules/jade/node_modules/mkdirp
Dependencies installed
-----> Discovering process types
Procfile declares types -> web
-----> Compiled slug size is 3.1MB
-----> Launching... done, v7

This was a heroku issue and appears to have gone away.

I'm going to go out on a limb here and say that it has something to do with parsing your package.json. Take a look at Specifying a version of Node.js/npm. Is everything valid JSON?
My guess is that this evalmachine is evaluating your package.json in a sandbox environment (see vm.runInNewContext), and lookupCode is some way of, first, checking engines.node, then engines.npm. Are both of these accessible? If this is the truth, then shame on Heroku's Devs for not expecting this error and accounting for it with some useful message. They're usually good about such things.

Related

Deployment on heroku failed

I want to deploy my exiting project on heroku, but it gives me an error.
structure of my file:
___instagram
__backend
_controllers
_images
_middleware
_models
_node_modules
_routes
_utiles
.gitignore
app.js
package-lock.json
package.json
Procfile
__ui
...
commands:
E:\Coding\projects\instagram>git add .
E:\Coding\projects\instagram>git commit -m "update controllers"
[master 086d891] update controllers
1 file changed, 1 insertion(+), 1 deletion(-)
E:\Coding\projects\instagram>cd backend
E:\Coding\projects\instagram\backend>git push -f heroku master
after the last command (git push -f heroku master) i got this error:
E:\Coding\projects\instagram\backend>git push -f heroku master
Enumerating objects: 16, done.
Counting objects: 100% (16/16), done.
Delta compression using up to 4 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 956 bytes | 956.00 KiB/s, done.
Total 10 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz
remote:
remote: ! ERROR: Application not supported by 'heroku/nodejs' buildpack
remote: !
remote: ! The 'heroku/nodejs' buildpack is set on this application, but was
remote: ! unable to detect a Node.js codebase.
remote: ! A Node.js app on Heroku requires a 'package.json' at the root of
remote: ! the directory structure.
remote: !
remote: ! If you are trying to deploy a Node.js application, ensure that this
remote: ! file is present at the top level directory. This directory has the
remote: ! following files:
remote: !
remote: ! backend/
remote: ! ui/
remote: !
remote: ! If you are trying to deploy an application written in another
remote: ! language, you need to change the list of buildpacks set on your
remote: ! Heroku app using the 'heroku buildpacks' command.
remote: !
remote: ! For more information, refer to the following documentation:
remote: ! https://devcenter.heroku.com/articles/buildpacks
remote: ! https://devcenter.heroku.com/articles/nodejs-support#activation
remote:
remote:
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to ins-app-clone.
remote:
To https://git.heroku.com/ins-app-clone.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/ins-app-clone.git'
Heroku buildpack looks at the top-level (root) for package.json.
The solution here is to use git sub-trees. I too was facing this issue where I had a Monorepo MERN codebase in which I wanted to deploy my server using Heroku and client via Vercel.
I have written a blog post regarding this, I'm sure you'll get an idea regarding a solution to this.
Link to Blog Post

heroku/python buildpack for node.js app get rejected

I have an Node.js app with Python scripts that I am trying to deploy to Heroku.
Every time I try to add the heroku/python buildpack the git push gets rejected.
remote: Could not find a version that satisfies the requirement pywin32==224 (from -r /tmp/build_ebad00f3b8d3c9b4b03965f0d0924e7a/requirements.txt (line 57)) (from versions: )
remote: No matching distribution found for pywin32==224 (from -r /tmp/build_ebad00f3b8d3c9b4b03965f0d0924e7a/requirements.txt (line 57))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to XXXXXX
remote:
To https://git.heroku.com/xxxxxx.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxxxx.git'
Without the heroku/python buildpack the push works fine. I think I need that buildback for my Python scripts work on web.
My app runs fine locally but everything related to Python is not working when deployed. I use Python 3.7.3 64-bit version.
I have runtime.txt and requirements.txt in root of my app.
My runtime.txt file:
python-3.7.3
requirements.txt:
altgraph==0.16.1
asn1crypto==0.24.0
astroid==2.1.0
awscli==1.16.209
beautifulsoup4==4.6.3
botocore==1.12.199
bs4==0.0.1
cached-property==1.5.1
cachetools==3.1.1
certifi==2019.6.16
cffi==1.12.2
chardet==3.0.4
colorama==0.3.9
cryptography==2.6.1
defusedxml==0.5.0
dnspython==1.16.0
docutils==0.14
et-xmlfile==1.0.1
exchangelib==1.12.2
future==0.17.1
google-api-python-client==1.7.9
google-auth==1.6.3
google-auth-httplib2==0.0.3
google-auth-oauthlib==0.4.0
googletrans==2.4.0
gspread==3.1.0
httplib2==0.13.0
idna==2.8
isodate==0.6.0
isort==4.3.4
jdcal==1.4
jmespath==0.9.4
lazy-object-proxy==1.3.1
lxml==4.3.2
macholib==1.11
mccabe==0.6.1
ntlm-auth==1.2.0
numpy==1.15.4
oauth2client==4.1.3
oauthlib==3.0.1
openpyxl==2.6.0
pandas==0.23.4
pefile==2018.8.8
py2exe==0.9.2.2
pyasn1==0.4.5
pyasn1-modules==0.2.5
pycparser==2.19
Pygments==2.3.1
pygsheets==2.0.1
PyInstaller==3.4
pylint==2.2.2
PyMySQL==0.9.3
pyodbc==4.0.26
PySocks==1.6.8
python-dateutil==2.7.5
pytz==2019.1
pywin32==224
pywin32-ctypes==0.2.0
pywinrm==0.3.0
PyYAML==5.1
requests==2.22.0
requests-kerberos==0.12.0
requests-ntlm==1.1.0
requests-oauthlib==1.2.0
rsa==3.4.2
s3transfer==0.2.1
selenium==3.141.0
six==1.11.0
soupsieve==1.8
stem==1.7.0
torrequest==0.1.0
tzlocal==1.5.1
uritemplate==3.0.0
urllib3==1.25.3
uuid==1.30
virtualenv==16.7.2
winkerberos==0.7.0
wrapt==1.10.11
xlrd==1.1.0
XlsxWriter==1.1.2
xmltodict==0.12.0
Appreciate any guidance.
Here's the problem:
Could not find a version that satisfies the requirement pywin32==224
Heroku doesn't run Windows, so pywin32 isn't available. I'm not sure what you're using that for. If you don't need it, remove it (along with pywin32-ctypes, pywinrm, and anything else that's Windows-dependent) then redeploy. If you're using those libraries you'll need to rewrite that portion of your code.
Generally speaking, your requirements.txt should only have things your application actually needs. I suspect that you've got a lot of things in there that you're not using. Maybe you're not using virtual environments?

Running Python Worker on Heroku - Push Failed

my scope is to run a python script (it does scrap text from websites and save it in csv files) in the cloud through cron job.
For this I chose Heroku.
I am stuck because when I try to deploy the worker I get a Push rejection.
Here is what i do:
I put my scrapit.py and Procfile ('worker: node scrapit.py') in a directory.
Then after I create an app in heroku, I send the following commands from the directory of above:
$ heroku login
$ git init
$ heroku git:remote -a app-name-on-heroku
$ git add .
$ git commit -am "nth time :("
$ git push heroku master
I get the following message:
Counting objects: 41, done. Delta compression using up to 4 threads.
Compressing objects: 100% (36/36), done. Writing objects: 100%
(41/41), 12.97 KiB | 0 bytes/s, done. Total 41 (delta 6), reused 0
(delta 0) remote: Compressing source files... done. remote: Building
source: remote: remote: -----> App not compatible with buildpack:
https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info:
https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote: remote: ! Push failed remote: Verifying deploy...
remote: remote: ! Push rejected to app-name-on-heroku. remote: To
https://git.heroku.com/app-name-on-heroku.git ! [remote rejected]
master -> master (pre-receive hook declined) error: failed to push
some refs to 'https://git.heroku.com/app-name-on-heroku.git'
after the error I sent this command:
heroku buildpacks:set heroku/python
but still the push gets rejected
Every Heroku buildpack specifies a bin/detect file, which lets the platform know if that buildpack can be used with that app or not.
The python buildpack requires either: requirements.txt, setup.py or Pipfile to be present.
You need to create (and properly configure) one of those files to be able to have your python app built.

"No default language could be detected for this app" while using multiple Buildpacks for an app on Heroku

I deploy to Heroku two nodejs projects each one in own folder -
NodejsExpressApp1 and NodejsConsoleApp1.
I have added to the app root the Procfile file with the following content -
web: node NodejsExpressApp1/app.js
worker: node NodejsConsoleApp1/app.js
Also I have set the BUILD_DIR config var to the NodejsExpressApp1 folder.
Locally everything works fine.
Below shown what I get while deploying -
c:\ExpressMultiProjectApp2>git push heroku master
Counting objects: 1506, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1401/1401), done.
Writing objects: 100% (1506/1506), 4.85 MiB | 92.00 KiB/s, done.
Total 1506 (delta 269), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to sheltered-mesa-74202.
remote:
To https://git.heroku.com/sheltered-mesa-74202.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/sheltered-mesa-74202.git'`
Thanks!
The issue was fixed after creation in the app root the package.json file -
{
"name": "nodejs-express-app1",
"version": "0.0.0",
"description": "Multiple Buildpacks App",
"author": { "name": "SimonBor" },
"dependencies": {
"express": "~4.9.0"
}
}
Setting variable BUILD_DIR is not necessary step.
Of course it is not the best practice solution but it allowed me to continue development.
I will be more then happy for a better solution.
Best regards!

Deploying Meteor 0.9.2.1 on Heroku

When I try to deploy my Meteor app to Heroku, it crashes on boot.
Exception from task: Error: function expects no more than -1 arguments
at /app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:26:10
at readUtf8FileSync (packages/boilerplate-generator/boilerplate-generator.js:7)
at packages/boilerplate-generator/boilerplate-generator.js:82
at Array.forEach (native)
at Function._.each._.forEach (packages/underscore/underscore.js:105)
at Boilerplate._generateBoilerplateFromManifestAndSource (packages/boilerplate-generator/boilerplate-generator.js:64)
at new Boilerplate (packages/boilerplate-generator/boilerplate-generator.js:17)
at generateBoilerplateInstance (packages/webapp/webapp_server.js:288)
at packages/webapp/webapp_server.js:556
at Function._.each._.forEach (packages/underscore/underscore.js:113)
throw err;
^
Error: function expects no more than -1 arguments
at Object.Future.wait (/app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:326:15)
at _.extend.runTask (packages/meteor/fiber_helpers.js:79)
at Object.WebAppInternals.generateBoilerplate (packages/webapp/webapp_server.js:553)
at Object.main (packages/webapp/webapp_server.js:773)
at /app/.meteor/heroku_build/app/programs/server/boot.js:194:27
- - - - -
at /app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:26:10
at readUtf8FileSync (packages/boilerplate-generator/boilerplate-generator.js:7)
at packages/boilerplate-generator/boilerplate-generator.js:82
at Array.forEach (native)
at Function._.each._.forEach (packages/underscore/underscore.js:105)
at Boilerplate._generateBoilerplateFromManifestAndSource (packages/boilerplate-generator/boilerplate-generator.js:64)
at new Boilerplate (packages/boilerplate-generator/boilerplate-generator.js:17)
at generateBoilerplateInstance (packages/webapp/webapp_server.js:288)
at packages/webapp/webapp_server.js:556
at Function._.each._.forEach (packages/underscore/underscore.js:113)
It seems that Npm.require('fs').readFile.length is undefined.
I'm using this buildpack. When I build the app locally and test with node main.js it works. Are there any other changes that I need to make to the buildpack for Meteor 0.9.2.1?
I figured out what the problem is, and it is not caused by the buildpack or Heroku.
I'm using Nodetime which wraps fs.readFile and then calls the original with apply. This is the reason why Npm.require('fs').readFile.length is 0 (not undefined like I had thought).

Resources