我正在嘗試在 2021 年(在 Ubuntu 上)運行一個演示 Angular專案,Intellij創建專案后,下一步是:
ng serve --open在終端。
這給出了以下錯誤:
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$
通過查看其中的代碼,ng.js它似乎是關于 node.js 版本的警告(我不清楚有什么語法錯誤)。
我應該怎么做才能解決這個問題?
我查看了 Intellij 專案設定,在node.js我看到的設定中:
節點解釋器:
~/.config/JetBrains/IntelliJIdea/node/node-v14.15.0-linux-x64/bin/node
包管理器:
~/.config/JetBrains/IntelliJIdea/node/node-v14.15.0-linux-x64/lib/node_modules/npm
在終端我得到:
$ nodejs --version
v4.2.6
和
$ npm --version
3.5.2
uj5u.com熱心網友回復:
ng serve據我所知,您正在終端中運行。在這種情況下,正在使用您的系統 Node.js 解釋器 (v. 4.2.6)。但僅從 Node.js 8 開始支持函式呼叫中的尾隨逗號,請參閱https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#browser_compatibility。因此錯誤。您需要將系統 Node.js 解釋器更新為 LTS 版本
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/457882.html
標籤:节点.js ubuntu npm 智能理念 角-cli
