【问题标题】:I am not able to install create react app on my m1 macbook pro我无法在我的 m1 macbook pro 上安装 create react 应用程序
【发布时间】:2022-01-04 08:41:36
【问题描述】:

请帮我解决这个错误

安装node.js并将其添加到路径后,我在iterm上运行了以下命令

npm install -g create-react-app

我收到以下错误

npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/create-react-app'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/create-react-app'
npm ERR! }
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amaterasu/.npm/_logs/2022-01-04T08_36_06_018Z-debug.log ```

【问题讨论】:

  • 你可以试试npx create-react-app myapp。您不需要在系统范围内安装create-react-app

标签: node.js reactjs npm create-react-app


【解决方案1】:

我今天早些时候遇到了这个问题,我是这样解决的。

  1. npm uninstall -g create-react-app
  2. npx clear-npx-cache
  3. npx create-react-app my-app

如果您对此问题的详细信息感兴趣,请查看this github thread

【讨论】:

    【解决方案2】:

    您需要节点版本 >=14 和 npm >=5.6 使用命令 npx create-react-app myapp。 https://reactjs.org/docs/create-a-new-react-app.html#create-react-app

    【讨论】:

      【解决方案3】:

      为 react 项目创建一个文件夹。 在终端中打开该文件夹。(命令行) 并使用npx create-react-app yourAppName。 上述错误与权限相关,您无权在“/usr/local/lib/node_modules/create-react-app”下创建新文件夹。 如果仍然出现此错误,请使用sudo npx create-react-app yourAppName

      【讨论】:

        【解决方案4】:

        对于你要全局安装的npm包,主要是你可能会遇到权限问题。这通常可以通过在第一行添加 sudo 来解决。所以而不是:

        create-react-app yourAppName
        

        你可以这样做:

        sudo npx create-react-app yourAppName
        

        遵循您的根用户密码。

        另外,为了补充更多,node js 版本和创建 react 应用程序存在一些问题。您可以通过终端上的以下命令检查 Mac 中安装的节点版本:

        node --version
        

        如果安装的Node版本是17.X,可以认为与问题有关。

        始终建议使用 LTS 版本。

        enter link description here

        【讨论】:

          猜你喜欢
          • 2023-02-20
          • 2022-01-03
          • 2021-06-27
          • 2021-04-24
          • 1970-01-01
          • 2022-01-17
          • 1970-01-01
          • 2022-07-01
          • 2022-01-18
          相关资源
          最近更新 更多