I am trying to run a demo Angular
project in Intellij
2021 (on Ubuntu), and after creating the project, the next step is:
ng serve --open
in the terminal.
Which gives the following error:
me@me:~/Projects/DemoApp$ ng serve --open
/home/me/Projects/DemoApp/node_modules/@angular/cli/bin/ng.js:35
);
^
SyntaxError: Unexpected token )
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
me@me:~/Projects/DemoApp$
From looking at the code in ng.js
it seems like it's a warning about node.js version (it's not clear to me what there is a Syntax Error).
What should I do to solve this problem?
I looked at the Intellij project settings, and in the node.js
settings I see:
Node interpreter:
~/.config/JetBrains/IntelliJIdea/node/node-v14.15.0-linux-x64/bin/node
Package manager:
~/.config/JetBrains/IntelliJIdea/node/node-v14.15.0-linux-x64/lib/node_modules/npm
In the terminal I get:
$ nodejs --version
v4.2.6
and
$ npm --version
3.5.2
CodePudding user response:
You are running ng serve
in terminal, as far as I can see. In this case, your system Node.js interpreter (v. 4.2.6) is being used. But trailing commas in function calls are only supported since Node.js 8, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#browser_compatibility. Thus the error. You need to update your system Node.js interpreter to LTS version