Reputation: 197
I am attempting to deploy my node js app to Heroku but it keeps failing.
I have already set NPM_CONFIG_PRODUCTION=false
. Build script works fine on my local machine
This is my package.json file
"release": "npm run clean && npm run build-app && npm run start",
"clean": "rm -rf dist && mkdir dist",
"build": "rm -rf ./dist && mkdir dist && babel . --out-dir dist",
"build-app": "babel . -s -d dist --presets=@babel/env --ignore node_modules",
Build should be successful but this is the error I get on Heroku
> rm -rf ./dist && mkdir dist && babel . --out-dir dist
[BABEL] Note: The code generator has deoptimised the styling of /tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/.heroku/node/lib/node_modules/npm/node_modules/ajv/dist/regenerator.min.js as it exceeds the max of 500KB.
{ SyntaxError: /tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/.heroku/node/lib/node_modules/npm/node_modules/cmd-shim/index.js: Legacy octal literals are not allowed in strict mode (166:15)
164 | function chmodShim (to, cb) {
165 | var then = times(2, cb, cb)
> 166 | fs.chmod(to, 0755, then)
| ^
167 | fs.chmod(to + ".cmd", 0755, then)
168 | }
169 |
at Parser.raise (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:3851:17)
at Parser.readNumber (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:4702:14)
at Parser.getTokenFromCode (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:4474:14)
at Parser.nextToken (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:4049:12)
at Parser.next (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:3989:10)
at Parser.eat (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:3994:12)
at Parser.expect (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:5153:10)
at Parser.parseCallExpressionArguments (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:6106:14)
at Parser.parseSubscript (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:6016:29)
at Parser.parseSubscripts (/tmp/build_3a8af19f4cfbd2b3f05ba2bc3775012d/node_modules/@babel/parser/lib/index.js:5935:19)
pos: 4390,
loc: Position { line: 166, column: 15 },
code: 'BABEL_PARSE_ERROR' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `rm -rf ./dist && mkdir dist && babel . --out-dir dist`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.zXFlw/_logs/2019-04-19T07_15_46_065Z-debug.log
-----> Build failed
Upvotes: 4
Views: 939
Reputation: 197
It seems the error was due to the .
flag in my build script telling babel to transpile my node_modules folder, even using the --ignore node_modules
flag refused to work for me for some yet to be understood reason. I had to restructure my entire folder to move my node_modules folder beyond the scope of my babel script to finally make it function properly
Upvotes: 3