现在如何在 RaspberryPi Zero 上使用 create-react-app?

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

我想在 RaspberryPi Zero W 上创建一个 React 应用程序。

现在,create-react-app需要NodeJs版本> = 14.x.x

我曾经选择https://nodejs.org/dist/中存在的构建来在RPZ上安装NodeJs,但兼容的版本停止在11.x.x

我尝试了以下方法:

  • create-react-app 与旧版本一起使用 npx create-react-app@4 my-app 但这会失败,并显示日志指出比当前版本旧版本不再支持全局安装。
  • 在本地安装 CRA@4 并从 /node_modules/.bin 执行 create-react-app 命令,但这会引发完全相同的错误。
  • https://unofficial-builds.nodejs.org/ 中安装非官方 NodeJs 构建,并通过 npx 执行最新版本的 CRA。但这些构建看起来不稳定...使用构建20.11.0,我收到了互联网断开错误日志(但连接实际上没问题),而使用构建14.21.3,我收到了内存不足的错误日志,在这两种情况下执行 create-react-app 命令时发生错误,导致失败。

现在如何在RaspberryPi Zero上使用create-react-app?

node.js create-react-app raspberry-pi-zero
1个回答
0
投票

如果您使用的是 Debian,那么您可以使用来自 https://nodesource.com 的二进制文件安装最新的 Node.js,然后使用 npx 创建一个 React 网站。

$ sudo apt update
$ sudo apt upgrade
$ curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&\
$ sudo apt-get install nodejs
$ npx create-react-app my-app
$ cd my-app
$ npm start
© www.soinside.com 2019 - 2024. All rights reserved.