Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.1K
Visualizações
Unknown error: SyntaxError: Unexpected token 'export' on ng command

I'm trying to learn Angular
I've followed the steps here: https://angular.io/guide/setup-local to get it setup on Ubuntu 18.04.5 LTS

When I try to create a new project with ng new I get an error:

$ node -v
v14.12.0

$ npm -v
6.14.8

$ ng new test
Unknown error: SyntaxError: Unexpected token 'export'

$ ng -v
Unknown error: SyntaxError: Unexpected token 'export'

I installed it via sudo npm install -g @angular/cli which gave no errors.

I've purged node sudo apt-get purge nodejs and reinstalled and removed ng sudo npm remove -g @angular/cli then reinstalled again sudo npm install -g @angular/cli, still get this error. Any ideas?

There was an older version of nodejs on the system originally; I upgraded to 14.x. Export is part of ES6, perhaps it's related? I can't seem to figure it out.

over 4 years ago · Santiago Trujillo
7 Respostas
Responde à pergunta

0

Run the following command on cmd. This recommends that you always update to the latest patch version, as it contains fixes we released since the initial major release. For example, use the following command to take the latest 10.x.x version and use that to update.

ng update @angular/cli@^<major_version> @angular/core@^<major_version>
over 4 years ago · Santiago Trujillo Relatório

0

First of all Don't run any command which is collected from here and there. Simply follow these steps.

1 uninstall current NodeJS version 2 download lowest version from here. 3 install the lower NodeJS version. 4 restart cmd Promat/terminal and try.

This worked for me.

over 4 years ago · Santiago Trujillo Relatório

0

Have encountered this error many a times in past. What worked for was removing the package.lock and node_modules & rerun the npm install.

cached code might be causing the trouble.

over 4 years ago · Santiago Trujillo Relatório

0

You are using an incompatible NodeJs version. Install a lower version.

More information here (webarchive version).

over 4 years ago · Santiago Trujillo Relatório

0

I had the same issue and I could fix it by downgrading node to v12.8.1

You could use nvm as follows:

install nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

refresh .profile

source ~/.profile

install node v12.8.1

nvm install v12.8.1

check that you are using the 12.8.1 version

nvm list

check ng again

ng -- version
over 4 years ago · Santiago Trujillo Relatório

0

Check for node versions. use nvm brew install nvm

I had the same problem. if you have any other version of Node that might fix it On the Angular Github node requirement is below

"engines": {
    "node": ">=10.13.0 <13.0.0",
    "yarn": ">=1.22.4"
  }

after installing the older version nvm install 12.4.0
then nvm use 12.4.0

this did the fix for me

over 4 years ago · Santiago Trujillo Relatório

0

For me no solution worked so I uninstalled everything, both the angular and node cli, thinking that it was a version error, but when I typed ng in the console, the error kept appearing so I found where ng was, with whereis ng, delete the file and install all over again.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda