После создания билда с его запуска я получаю ошибку SyntaxError: Unexpected token '<' Как исправить?
Задача поставить приложение на сервер. Начну с того, что если я просто переношу app на сервер и делаю npm start то app запускается и работает нормально.
Если я делаю билд проекта то он создается с ошибками, но без проблем запускается. Вот после того как я сделал билд с его запустил я получаю в консоле вот такую ошибку:
далее ошибки которые возникают при создании билда:
Creating an optimized production build...
Compiled with warnings.
./src/containers/home/TrendingPosts/index.jsx
Line 11:6: React Hook useEffect has a missing dependency: 'getTrending'. Either include it or remove the dependency array. If 'getTrending' changes too often, find the parent component that defines it and wrap that definition in useCallback react-hooks/exhaustive-deps
./src/containers/image/index.jsx
Line 25:6: React Hook useEffect has a missing dependency: 'getImageData'. Either include it or remove the dependency array. If 'getImageData' changes too often, find the parent component that defines it and wrap that definition in useCallback react-hooks/exhaustive-deps
./src/components/simple/post/index.jsx
Line 28:46: Unexpected string concatenation of literals no-useless-concat
./src/components/Routes.jsx
Line 2:32: 'Redirect' is defined but never used no-unused-vars
Line 40:6: React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/containers/Tape/index.jsx
Line 30:6: React Hook useEffect has missing dependencies: 'getImagesHandler' and 'loading'. Either include them or remove the dependency array react-hooks/exhaustive-deps
Line 34:6: React Hook useEffect has a missing dependency: 'getImagesHandler'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/containers/NavBar/index.jsx
Line 32:6: React Hook useEffect has a missing dependency: 'getUserBalance'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/core/hooks/useLikes.js
Line 35:19: 'res' is assigned a value but never used no-unused-vars
Line 67:38: The ref value 'el.current' will likely have changed by the time this effect cleanup function runs. If this ref points to a node rendered by React, copy 'el.current' to a variable inside the effect, and use that variable in the cleanup function react-hooks/exhaustive-deps
Line 68:8: React Hook useEffect has a missing dependency: 'handler'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/containers/editPost/index.jsx
Line 37:6: React Hook useEffect has a missing dependency: 'getPostData'. Either include it or remove the dependency array. If 'getPostData' changes too often, find the parent component that defines it and wrap that definition in useCallback react-hooks/exhaustive-deps
./src/components/smart/search/result/index.jsx
Line 3:16: 'object' is defined but never used no-unused-vars
./src/core/hooks/uploadFiles.js
Line 43:6: React Hook useEffect has missing dependencies: 'files' and 'uiFiles'. Either include them or remove the dependency array react-hooks/exhaustive-deps
./src/containers/auth/walletConnect/index.jsx
Line 48:7: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
./src/components/ordinary/TopPosts/TopPosts.jsx
Line 4:10: 'swiperSettings' is defined but never used no-unused-vars
./src/components/simple/RightNav/index.jsx
Line 4:8: 'Link' is defined but never used no-unused-vars
./src/containers/auth/metamask/index.jsx
Line 50:13: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
./src/core/api/likes/index.js
Line 5:15: 'res' is assigned a value but never used no-unused-vars
./src/core/api/user/index.js
Line 61:13: 'user' is assigned a value but never used no-unused-vars
Line 72:13: 'res' is assigned a value but never used no-unused-vars
Line 81:13: 'res' is assigned a value but never used no-unused-vars
./src/containers/user/index.jsx
Line 64:6: React Hook useEffect has a missing dependency: 'getUserDataQuery'. Either include it or remove the dependency array react-hooks/exhaustive-deps
./src/components/ordinary/formPost/index.jsx
Line 6:8: 'Link' is defined but never used no-unused-vars
./src/components/smart/createPost/index.jsx
Line 7:8: 'Link' is defined but never used no-unused-vars
./src/components/smart/tape/index.jsx
Line 7:9: The 'scrollHandler' function makes the dependencies of useEffect Hook (at line 25) change on every render. Move it inside the useEffect callback. Alternatively, wrap the 'scrollHandler' definition into its own useCallback() Hook react-hooks/exhaustive-deps
./src/containers/home/TopPosts/index.jsx
Line 9:6: React Hook useEffect has a missing dependency: 'getTopPosts'. Either include it or remove the dependency array. If 'getTopPosts' changes too often, find the parent component that defines it and wrap that definition in useCallback react-hooks/exhaustive-deps
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
File sizes after gzip:
456.65 KB build\static\js\2.06539643.chunk.js
27.42 KB build\static\js\main.56d9c162.chunk.js
3.49 KB build\static\css\main.c9e009c8.chunk.css
3.33 KB build\static\css\2.b49f9c43.chunk.css
1.73 KB build\static\js\3.f7997a40.chunk.js
1.17 KB build\static\js\runtime-main.6d09a018.js
The project was built assuming it is hosted at ./public/.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
Find out more about deployment here:
bit.ly/CRA-deploy
Насколько я понимаю тут нету ничего критичного в этих ошибках. Через npm start все работает и ошибки в консоле так же есть, но проект запускается, а вот при билде получаю вот такой результат. В чем может быть дело?
Ответы (2 шт):
нажми на ошибку (там где написан номер.chunk.js) - что бы развернуть код, где она происходит и через глобальный поиск попробуй найти это место
Решил вопрос. Дело все было в параметре homepage в package.json. Я просто удалил этот параметр и все заработало. Вебпак новенький как то странно работает с параметром homepage, пытаясь в жс засунуть голый хтмл, из за этого и проблема.