[英]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.