问题描述
限时送ChatGPT账号..我使用的是 Ubuntu 16.04.3 LTS,我使用 sudo apt-get install npm node
安装了 npm 和 node.之后,我使用 sudo npm install @angular/cli -g
安装了 @angular/cli
.
I'm on Ubuntu 16.04.3 LTS, and I installed npm and node by using sudo apt-get install npm node
. After that I installed @angular/cli
with sudo npm install @angular/cli -g
.
但是当我尝试使用 ng new hello-world
创建一个新项目时,它失败并显示以下错误:
But when I try to create a new project with ng new hello-world
, it fails with this error:
/usr/local/lib/node_modules/@angular/cli/models/config/config.js:17
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
如何让 ng new
工作?
推荐答案
原来是因为 Ubuntu 在 repos 中有一个旧版本的 node.我按照 https://nodejs 上的说明安装了更新版本,从而修复了错误/en/download/package-manager/
It turned out it was because Ubuntu has an old version of node in the repos. I fixed the error by installing a more recent version following the instructions at https://nodejs/en/download/package-manager/
curl -sL https://deb.nodesource/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
这篇关于ng new 失败并显示“SyntaxError: Unexpected token =";在 Ubuntu 上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论