简体   繁体   English

无法将 create-react-app 部署到 github-pages

[英]cannot deploy create-react-app to github-pages

I'm trying to deploy a react app using gh-pages, the build is generated successfully but at the moment of deployment I get this error:我正在尝试使用 gh-pages 部署 React 应用程序,构建成功生成但在部署时我收到此错误:

> reactapp@0.1.0 deploy C:\Users\javier\Desktop\Code\React1.0\1.1\CV19\reactapp
> gh-pages -d build

warning: failed to remove node_modules/jest-environment-jsdom-fourteen/node_modules/jsdom/lib/jsdom/living/constraint-validation/DefaultConstraintValidation-impl.js: Filename too long

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR!reactapp@0.1.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

My package.json:我的 package.json:

  {
  "homepage ": "http://javier.github.io/reactapp",
  "name": "reactapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "@material-ui/icons": "^4.9.1",
    "@reduxjs/toolkit": "^1.4.0",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "axios": "^0.21.0",
    "gh-pages": "^2.0.1",
    "mapbox-gl": "^1.12.0",
    "react": "^16.13.1",
    "react-bootstrap-icons": "^1.0.0",
    "react-dom": "^16.13.1",
    "react-map-gl": "^5.2.8",
    "react-mapbox-gl": "^5.0.0",
    "react-redux": "^7.2.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.0",
    "redux": "^4.0.5"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Anyone knows what could cause this error?任何人都知道可能导致此错误的原因是什么?

This is caused by Windows itself.这是由 Windows 本身引起的。

Under the Windows file naming system the total name or path cannot exceed 259 characters.在 Windows 文件命名系统下,总名称或路径不能超过 259 个字符。 This includes the folder path, file name and file extension.这包括文件夹路径、文件名和文件扩展名。 If it does, then when you try to delete or move it, you will receive this error.如果是这样,那么当您尝试删除或移动它时,您将收到此错误。

I've fixed this issue by renaming the folder(s) or file(s) affected.我通过重命名受影响的文件夹或文件解决了这个问题。 In your case the file is located in the node_modules folder which makes it a bit harder to deal with.在您的情况下,该文件位于 node_modules 文件夹中,这使得处理起来有点困难。

I would suggest moving the app to a top level folder - not in a nested folder on your desktop.我建议将应用程序移动到顶级文件夹 - 而不是桌面上的嵌套文件夹。

Edit: there is a similar question on the Microsoft's help forum which might be helpful.编辑:Microsoft 的帮助论坛上有一个类似的问题,可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Github页面上的Create-React-App返回一个空白页面 - Create-React-App on Github-pages returns a blank page 无法在 Github 页面上部署新的 create-react-app - Cannot deploy fresh create-react-app on Github Pages 使用 create-react-app 将 React 应用程序部署到 github 页面不起作用 - Deploy React app using create-react-app to github pages isn't working 将create-react-app应用程序部署到github页面可以很好地构建,但是不会部署 - deploying create-react-app app to github pages builds fine but won't deploy 如何将 create-react-app 部署到 github 页面? 收到“致命:无法从远程存储库读取”。 - How to deploy create-react-app to github pages? getting "fatal: Could not read from remote repository." 无法使用Create-React-App在github页面中发布我的React App-控制台出现错误 - Cannot publish my react App in github Pages with Create-React-App - got an Error in console 使用create-react-app + github页面的自定义域名 - Custom domain name with create-react-app + github pages create-react-app gh-pages 使用代理部署 - create-react-app gh-pages deploy with proxy 使用github页面的create-react-app的自定义域 - Custom domain using create-react-app for github pages 如何以root用户身份使用create-react-app更新自定义GitHub Pages - how to update a custom GitHub Pages with create-react-app as root
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM