Erro ao usar create-react-app em node.js no Windows 7 de 64 bits

2

Instalei node.js e recebo um erro ao usar o seguinte comando:

create-react-app <folder name>

A saída é:

Creating a new React app in C:\Users\Desktop\my-react-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...


> [email protected] postinstall C:\Users\Desktop\my-react-app\n
ode_modules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm ERR! path C:\Users\Desktop\my-react-app\node_modules\nan\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Desktop\my
-react-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, unlink 'C:\Users\Desktop
\my-react-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'C:\Users\Desktop\my-react-app\node_modules\nan\package.json\'\n    at Error (nati
ve)',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\Users\Desktop\my-react-app\node_modules\nan\pac
kage.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\AppData\Roaming\npm-cache\_logs17-09-07T11_17_31_8
99Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts
 has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting my-react-app / from C:\Users\Desktop
Done.

O problema persiste quando é executado como administrador:

Your environment has been set up for using Node.js 6.11.3 (x64) and npm.

C:\Windows\System32>npm install -g create-react-app
C:\Users\amar\AppData\Roaming\npm\create-react-app -> C:\Users\amar\AppData\R
ing\npm\node_modules\create-react-app\index.js
+ [email protected]
updated 1 package in 17.296s

C:\Windows\System32>create-react-app react-app

Creating a new React app in C:\Windows\System32\react-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...


> [email protected] postinstall C:\Windows\System32\react-app\nod
odules\uglifyjs-webpack-plugin
> node lib/post_install.js

npm ERR! path C:\Windows\System32\react-app\node_modules\nan\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Windows\System32\r
t-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, unlink 'C:\Windows\System3
eact-app\node_modules\nan\package.json'
npm ERR!     at Error (native)
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink \'C:\Window
System32\react-app\node_modules\nan\package.json\'\n    at Error (native)
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\Windows\System32\react-app\node_modules\nan\packag
son' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\amar\AppData\Roaming\npm-cache\_logs17-09-07T17_16_1
06Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scri
 has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting react-app / from C:\Windows\System32
Done.

C:\Windows\System32>
    
por amar 07.09.2017 / 13:31

1 resposta

0

É uma pena que você tenha deixado de fora o caminho - provavelmente é o culpado.

Esta mensagem de erro indica que o npm não tem permissões para executar alguma operação de arquivo:

npm ERR! Please try running this command again as root/Administrator.

Isso pode acontecer ao executar npm install -g <something> (instalando algo globalmente), mas para instalações locais geralmente indica seu erro no caminho.

E, de fato, o caminho da segunda linha parece negativo:

Creating a new React app in C:\Users\Desktop\my-react-app.

Seu nome de usuário está faltando! C:\Users contém perfis de usuários, que contêm Desktop pastas. Portanto, o caminho deve ser C:\Users\ YourUsername \Desktop\my-react-app .

    
por 07.09.2017 / 18:10

Tags