11
respostas

Não consigo instalar o angular cli

Tentei instalar em uma nova máquina, mas recebo esses erros:

npm WARN checkPermissions Missing write access to /usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules
npm ERR! path /usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/usuario/.npm/_logs/2019-09-16T15_34_13_203Z-debug.log

Como resolver?

11 respostas

Oi Henrique tudo bem ?

Como vamos fazer uma instalação global, precisamos de permissão de administrador.

No linux: sudo npm install -g @angular/cli@6.0.7

No windows temos que abrir o terminal em modo administrador

Obrigado por responder.

Não está mais dando erro, conclui normal. Porém fica como se não tivesse instalado nada, o terminal do linux não reconhece o comando "ng".

Depois de instalar o angular cli, quando eu digito o comando ng recebo a mensagem:

Command 'ng' not found, but can be installed with:

sudo apt install ng-common

Alguém sabe alguma solução?

Pode ser um problema com npm, vamos tentar desinstalar e instalar novamente:

sudo npm rm -g angular-cli
npm cache clear
sudo npm install -g angular-cli

Quando eu digito npm cache clear, recebo isso:

npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. On the other hand, if you're debugging an issue with the installer, you can use `npm install --cache /tmp/empty-cache` to use a temporary cache instead of nuking the actual one.
npm ERR! 
npm ERR! If you're sure you want to delete the entire cache, rerun this command with --force.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2019-09-19T14_28_34_463Z-debug.log

Você pode me explicar o que os comandos "sudo npm rm -g angular-cli" e "npm cache clear" fizeram?

Porque agora quando eu tento instalar com o comando que eu usava antes: "sudo npm install -g @angular/cli", o terminal trava na primeira linha e não termina.

Se eu digitar: "sudo npm install -g @angular/cli@6.0.7" recebo a mensagem:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "angular/cli@6.0.7" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2019-09-19T14_56_54_512Z-debug.log

E o comando sudo "npm install -g angular-cli@6.0.7" recebo:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for angular-cli@6.0.7.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2019-09-19T15_01_03_827Z-debug.log

E se eu digitar "sudo npm install -g angular-cli" recebo:

npm WARN @angular/core@2.4.10 requires a peer of rxjs@^5.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/angular-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.12.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2019-09-19T14_59_36_741Z-debug.log

ou seja, ferrou tudo aqui, o que eu faço agora?

Os comandos são para remover o cli, limpar o cache e instalar novamente.

Aparentemente não removeu todo o cli do angular, você pode tentar do seguinte modo

sudo npm uninstall -g @angular/cli

sudo npm install -g @angular/cli@6.0.7

Com o comando "sudo npm uninstall -g @angular/cli"

Estou recebendo esse erro:

npm ERR! code EEXIST
npm ERR! path /usr/local/lib/nodejs/node-v10.16.3-linux-x64/bin/ng
npm ERR! Refusing to delete /usr/local/lib/nodejs/node-v10.16.3-linux-x64/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules/@angular/cli
npm ERR! File exists: /usr/local/lib/nodejs/node-v10.16.3-linux-x64/bin/ng
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2019-09-19T15_18_22_259Z-debug.log

humm ficou algum resquicio do ng ainda

rm -rf vai remover o que sobrou do ng ainda

sudo rm -rf /usr/local/bin/ng 


sudo npm uninstall -g @angular/cli

sudo npm install -g @angular/cli@6.0.7

Não funcionou,

Eu decidi remover o usuário e criar outro, mas agora ao digitar o comando: "sudo npm install -g @angular/cli@6.0.7", está dando esse erro.

npm ERR! code EEXIST
npm ERR! path /usr/local/lib/nodejs/node-v10.16.3-linux-x64/bin/ng
npm ERR! Refusing to delete /usr/local/lib/nodejs/node-v10.16.3-linux-x64/bin/ng:
 ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by 
npm /usr/local/lib/nodejs/node-v10.16.3-linux-x64/lib/node_modules/@angular/cli
npm ERR! File exists: /usr/local/lib/nodejs/node-v10.16.3-linux-x64/bin/ng
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2019-09-20T11_16_10_981Z-debug.log

Sabe dizer se existe algum fórum específico de Angular onde eu possa tirar essa dúvida?

Eu desisti de instalar o angular/cli nessa máquina, pode encerrar o tópico.

Obrigado pela ajuda.