4

When I push to heroku master, my deployment is failing with the following error:

remote: { SyntaxError: /tmp/build_396711075a2ae75358d2c942f9c73c1c/.heroku/node/lib/node_modules/npm/node_modules/cmd-shim/index.js: Legacy octal literals are not allowed in strict mode (166:15)
remote: 
remote:   164 | function chmodShim (to, cb) {
remote:   165 |   var then = times(2, cb, cb)
remote: > 166 |   fs.chmod(to, 0755, then)
remote:       |                ^
remote:   167 |   fs.chmod(to + ".cmd", 0755, then)
remote:   168 | }
remote:   169 | 
remote:     at Parser.raise (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:6344:17)
remote:     at Parser.readNumber (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:7194:14)
remote:     at Parser.getTokenFromCode (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:6966:14)
remote:     at Parser.nextToken (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:6542:12)
remote:     at Parser.next (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:6482:10)
remote:     at Parser.eat (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:6487:12)
remote:     at Parser.expect (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:7645:10)
remote:     at Parser.parseCallExpressionArguments (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:8605:14)
remote:     at Parser.parseSubscript (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:8515:29)
remote:     at Parser.parseSubscripts (/tmp/build_396711075a2ae75358d2c942f9c73c1c/node_modules/@babel/parser/lib/index.js:8434:19)
remote:   pos: 4390,
remote:   loc: Position { line: 166, column: 15 },
remote:   code: 'BABEL_PARSE_ERROR' }

My babel configuration is as shown below:

{
  "presets": [
    [
    "@babel/preset-env", {
      "targets": {
        "node": "current"
      }
    }
  ]
],
  "plugins": [
    "@babel/plugin-proposal-object-rest-spread",
    ["@babel/plugin-transform-classes", {
      "loose": true
    }]
  ]
}

What could be the issue?

James Z
  • 12,209
  • 10
  • 24
  • 44
Allan Mogusu
  • 220
  • 1
  • 15

1 Answers1

0

0755 gets interpreted as an octal number, which all start, ( edit: used to start ) with 0 in javascript, hence the error. So 0755 is technically the decimal number 493 and gets interpreted that way.

The real problem here is that there's no such thing as leading zeroes for numbers.

The quick fix is to either use the number 755, without the leading 0, or use the string "0755". No idea how that will affect the rest of the code though. If octal is needed, maybe babel has parsing options for octals you can add to the config?

EDIT:

Apparently, it's also forbidden to use octal literals with this syntax in strict mode.

Number with leading zero in JavaScript

So if you need the octal number, try 0o755.

Shilly
  • 8,511
  • 1
  • 18
  • 24
  • 2
    This error is being thrown by something in node modules when I deploy to Heroku and I can't change that. Secondly, It works fine locally – Allan Mogusu Jun 14 '19 at 07:09