Reputation: 2212
I've been trying to deploy an Angular Universal app to heroku
No matter what I do the same error is returned "failed to compile Node.js app."
I've set up a procfile, I've specified "engines" (I've tried at the start and the end of the script),
I've moved some packages form devDependencies to dependencies in package.json (At one point putting all packages in to dependencies)
I've tried, committing my node folder.
I even used a completely different package.json And it still gives me exactly the same response!!?
Which tells me; I think, that it has nothing to do with dependancies, I'm using for this project?
using:
git add .
git commit -m"message"
git push heroku master
The response:
Compressing objects: 100% (252/252), done.
Writing objects: 100% (256/256), 3.20 MiB | 319.00 KiB/s, done.
Total 256 (delta 116), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 8.x...
remote: Downloading and installing node 8.11.2...
remote: Using default npm version: 5.6.0
remote:
remote: -----> Restoring cache
remote: Skipping cache restore (not-found)
remote:
remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: npm ERR! Unexpected token < in JSON at position 108
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.j8wgx/_logs/2018-05-21T14_34_17_856Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to ma-leon.
remote:
To https://git.heroku.com/ma-leon.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/ma-leon.git'
My package.json:
{
"name": "maleon",
"version": "1.0.0",
"license": "MIT",
"main": "index.js",
"scripts": {
"ng": "ng",
"start": "node index.js",
"build:es2015": "node node_modules/babel-cli/bin/babel.js node_modules/ngx-page-scroll/ --out-dir node_modules/ngx-page-scroll/ --presets es2015",
"postinstall": "npm run build:es2015 && ng build --prod && ng build --prod --app 1 --output-hashing none",
"fix-scroll": "node node_modules/babel-cli/bin/babel.js node_modules/ngx-page-scroll/ --out-dir node_modules/ngx-page-scroll/ --presets es2015",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.10",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.10",
"@angular/forms": "^5.2.10",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/platform-server": "^5.2.10",
"@angular/router": "^5.2.0",
"@nguniversal/express-engine": "^5.0.0",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0",
"babel-cli": "^6.26.0",
"body-parser": "^1.17.1",
"bootstrap": "^3.3.7",
"core-js": "^2.5.3",
"express": "^4.15.2",
"emailjs": "^1.0.10",
"jquery": "^3.2.1",
"linkify": "^0.2.1",
"linkifyjs": "^2.1.6",
"ng2-bootstrap": "^1.6.3",
"ngx-page-scroll": "^4.0.2",
"rxjs": "^5.2.0",
"socket.io-client": "^1.7.3",
"ts-helpers": "^1.1.1",
"web-animations-js": "^2.2.5",
"zone.js": "0.8.5"
},
"devDependencies": {
"@angular/cli": "~1.7.4",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"popper.js": "^1.14.3",
"protractor": "~5.1.2",
"request": "^2.81.0",
"smoothscroll-polyfill": "^0.4.0",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
},
"engines": {
"node": "9.x"
}
}
Upvotes: 0
Views: 314
Reputation: 2212
In the end, this was to do with how I was pushing to heroku
Because I was on a branch, I should have been using:
git add .
git commit -m"message"
git push heroku <branchname:>master
Upvotes: 0
Reputation: 137183
This is described in the common errors section of NPM's documentation:
Invalid JSON
Error: Invalid JSON npm ERR! SyntaxError: Unexpected token < npm ERR! registry error parsing json
- Possible temporary npm registry glitch, or corrupted local server cache. Run
npm cache clean
and/or try again later.- This can be caused by corporate proxies that give HTML responses to
package.json
requests. Check npm's proxy configuration.- Check that it's not a problem with a package you're trying to install (e.g. invalid
package.json
).
Your package.json
contains valid JSON. Try checking your package.lock
.
Upvotes: 1