在 pythonanywhere 上安装现有 DRF React 应用程序时出现问题

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

我需要什么?

在 pythonanywhere 上安装并运行下面链接中给定的应用程序代码

https://github.com/veryacademy/YT-Django-DRF-Simple-Blog-Series-JWT-Part-3.git

先决条件是安装 npm、npx。为此,我参考了页面

https://help.pythonanywhere.com/pages/React/

我正在尝试什么?

CMIIAW。我认为 git 中的“react”文件夹已经是一个 create-react-app (减去 node_modules )

因此,要创建node_modules文件夹,我可以创建一个名为“frontend”的新react应用程序,并将node_modules复制到“react”文件夹中

npm install -g react create-react-app
npx create-react-app frontend

我得到了什么?

(.myenv) 04:01 ~/YT-Django-DRF-Simple-Blog-Series-Part-1/react (master)$ npx create-react-app frontend --force

Creating a new React app in /home/nightly/YT-Django-DRF-Simple-Blog-Series-Part-1/react/frontend.

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

npm ERR! code Unknown system error -122
npm ERR! syscall write
npm ERR! errno -122
**npm ERR! Unknown system error -122: Unknown system error -122, write
**
npm ERR! A complete log of this run can be found in: /home/nightly/.npm/_logs/2024-04-20T04_01_57_768Z-debug-0.log

Aborting installation.
  npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting frontend/ from /home/nightly/YT-Django-DRF-Simple-Blog-Series-Part-1/react
Done.

即使是 --force 选项在这里也没有帮助。 如何解决这个问题,以便我可以顺利运行这段代码。

reactjs django django-rest-framework pythonanywhere
1个回答
0
投票

检查权限:确保您拥有全局安装软件包所需的权限。如果遇到权限错误,请考虑使用 nvm(节点版本管理器)等包管理器来管理 Node.js 安装,而无需 sudo 权限。 查看 npm 日志:查看 npm 调试日志 (/home/nightly/.npm/_logs/2024-04-20T04_01_57_768Z-debug-0.log),了解有关错误的更多详细信息。日志可能会提供有关导致安装失败的原因的线索。 手动安装:如果所有其他方法都失败,您可以尝试一一手动安装每个依赖项。从核心依赖项(react、react-dom、react-scripts、cra-template)开始,看看在此过程中是否遇到任何错误。 成功安装依赖项并解决所有问题后,您应该能够在 PythonAnywhere 上顺利运行 React 应用程序。

有关更详细的说明和故障排除提示,您可以访问我们的网站 [webhostwinner. com](https://www.webhostwinner.com),我们提供有关 Web 开发的全面指南和教程,包括在 PythonAnywhere 上部署 React 应用程序。另外,不要忘记查看我们的独家折扣,让您的托管体验更加实惠!

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