create-react-app安装过程中出现问题

问题描述 投票:0回答:2

[我正在尝试学习如何使用React,但是我对create-react-app有问题:https://create-react-app.dev/docs/getting-started/

我在使用的安装过程中遇到问题

npx create-react-app my-app
cd my-app
npm start

按照本教程的建议。

我所做的只是npx create-react-app my-app,但从终端获得的错误是

Qubes-MacBook-Pro:~ qube$ pwd
/Users/qube
Qubes-MacBook-Pro:~ qube$ ls
Applications        Desktop         Downloads       Movies          NetBeansProjects    Postman         apache-maven-3.6.1  docker          package-lock.json
Books           Documents       Library         Music           Pictures        Public          apache-tomcat-8.5.11    node_modules
Qubes-MacBook-Pro:~ qube$ npx create-react-app my-app
npm ERR! path /Users/qube/.npm/_cacache/index-v5/4c/c4
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/Users/qube/.npm/_cacache/index-v5/4c/c4'
npm ERR!  { [Error: EACCES: permission denied, mkdir '/Users/qube/.npm/_cacache/index-v5/4c/c4']
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, mkdir '/Users/qube/.npm/_cacache/index-v5/4c/c4'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'mkdir',
npm ERR!      path: '/Users/qube/.npm/_cacache/index-v5/4c/c4' },
npm ERR!   isOperational: true,
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, mkdir \'/Users/qube/.npm/_cacache/index-v5/4c/c4\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/Users/qube/.npm/_cacache/index-v5/4c/c4',
npm ERR!   parent: 'external-editor' }
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!     /Users/qube/.npm/_logs/2019-12-22T01_29_40_120Z-debug.log
Install for create-react-app@latest failed with code 243

我尝试寻找修复程序,但建议使用sudo chown -R $USER /usr/local/lib/node_modules

如何解决此问题?

node.js reactjs npm create-react-app npx
2个回答
0
投票

这似乎是权限问题。您可以手动创建此目录并尝试重新运行它吗?用户/qube/.npm/_cacache/index-v5/4c/c4。


0
投票

意识到您不应该在用户名/用户名目录中使用该命令,因为它会引起问题,因此请使用

npx create-react-app my-app
cd my-app
npm start

例如,在您的应用程序目录中,在您台式机的目录中

© www.soinside.com 2019 - 2024. All rights reserved.