[英]cannot deploy create-react-app to github-pages
我正在嘗試使用 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.
我的 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"
},
任何人都知道可能導致此錯誤的原因是什么?
這是由 Windows 本身引起的。
在 Windows 文件命名系統下,總名稱或路徑不能超過 259 個字符。 這包括文件夾路徑、文件名和文件擴展名。 如果是這樣,那么當您嘗試刪除或移動它時,您將收到此錯誤。
我通過重命名受影響的文件夾或文件解決了這個問題。 在您的情況下,該文件位於 node_modules 文件夾中,這使得處理起來有點困難。
我建議將應用程序移動到頂級文件夾 - 而不是桌面上的嵌套文件夾。
編輯:Microsoft 的幫助論壇上有一個類似的問題,可能會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.