I'm trying to use the optional chaining operator in Nodejs. I have Windows 10 with nvm installed. I have tried my script with node 14.5 and 15 but the response is always the same:
C:\Users\user1\AppData\Roaming\nvm\v15.6.0\node64.exe C:\Users\user1\AppData\Roaming\nvm\v15.6.0\node_modules\npm\bin\npm-cli.js run exec-list --scripts-prepend-node-path=auto
> [email protected] exec-list
> node src/exec.js list json=myfile.json
C:\xampp\htdocs\oracle-node-service\src\exec.js:388
...setup.templates.handlebars?.filters?.FILTERS[0].COLUMNS_UNIQUE,
^
SyntaxError: Unexpected token .
This is started by phpstorm, I have tried to add this annotation in package.json but it doesn't work:
"engines": {
"node": "14.x"
}
{
"name": "oracle-node-service",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"build": "babel ./src --out-dir ./build",
"start": "node src/index.js",
"start-dev": "nodemon --exec babel-node src/index.js",
"lint": "eslint .",
"test": "echo \"Error: no test specified\" && exit 1",
"exec": "node src/exec.js list detail filters json=myfile.json",
"exec-list": "node src/exec.js list json=myfile.json",
"exec-detail": "node src/exec.js detail json=myfile.json",
"exec-filters": "node src/exec.js list detail filters json=configuration-filters.json",
"exec-list-detail": "node src/exec.js list detail json=configuration-list-detail.json",
"exec-filters-list-detail": "node src/exec.js filters list detail json=configuration-filters-list-detail.json"
},
"license": "ISC",
"devDependencies": {
"@babel/cli": "^7.14.5",
"@babel/core": "^7.14.6",
"@babel/node": "^7.14.5",
"@babel/preset-env": "^7.14.5",
"@babel/runtime": "^7.14.6",
"eslint": "^7.29.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"nodemon": "^2.0.7"
},
"dependencies": {
"handlebars": "^4.7.7",
"moment": "^2.29.1",
"oracledb": "^5.2.0",
"prompt-sync": "^4.2.0",
"lodash": "^4.17.21"
},
"engines": {
"node": "14.x"
}
}
Engines in package.json specify what version of Node.js should be supported. See docs. Optional chaining supported from Node.js version 14. Try to check what node version you have currently.
node -v
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With