I'm attempting to use optional chaining in my v14.17.5 NodeJS server, but get the following error whenever I use it:
/app/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^
SyntaxError: /app/src/schema/index.js: Unexpected token (64:30)
62 | return response;
63 | } catch (error) {
> 64 | const errCode = error?.response.error.errCode === 'CannotFind' ? 404 : 500;
| ^
It looks like there's an issue with the babel-core
dependency, but I don't have that dependency installed, so I'm not sure what to do. I have the following babel packages installed:
"@babel/helper-hoist-variables": "^7.14.5",
"babel-cli": "6.23.0",
"babel-eslint": "10.1.0",
"babel-plugin-transform-async-to-module-method": "6.22.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.23.0",
"babel-plugin-transform-flow-strip-types": "6.22.0",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"babel-preset-latest": "6.22.0",
"eslint-plugin-babel": "4.0.1",
My start
script is the following:
scripts {
"start": "nodemon ./src/index.js --exec babel-node --watch ./src |
bunyan",
}
PS - I'm unsure what babel-node
is doing here. If I could remove it some how that'd be awesome.