C
C
ceeed2022-02-20 18:43:39
Software Deployment
ceeed, 2022-02-20 18:43:39

When deploying a project to a server via build, it gives an error, what should I do?

I have a task to deploy a project to a windows server via build.
At my place, I do npm run build and then I get build but with errors, but as I understand it, they should not interfere with the work of the app. This is what I get when I build the project:

> react-scripts build

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/auth/metamask/index.jsx
  Line 16:11:  'width' is assigned a value but never used                                                                                    no-unused-vars
  Line 51:55:  Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank

./src/components/ordinary/Marquee/index.jsx
  Line 17:24:  Unexpected template string expression  no-template-curly-in-string
  Line 18:24:  Unexpected template string expression  no-template-curly-in-string
  Line 19:24:  Unexpected template string expression  no-template-curly-in-string

./src/components/ordinary/user/index.jsx
  Line 1:17:  'useRef' is defined but never used  no-unused-vars

./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/App.js
  Line 2:28:  'useState' is defined but never used  no-unused-vars

./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/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.41 KB   build\static\js\main.d8599842.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

Далее я запускаю проект на сервере через serve -s build -l 5000
и получаю извещение, что проект запущен:
INFO: Accepting connections at http://localhost:5000

Далее я захожу по адресу и вижу ошибку в консоле:
adblock-onpage-icon-cs.js:172 Uncaught ReferenceError: browser is not defined
    at onScriptLoad (adblock-onpage-icon-cs.js:172:3)
    at adblock-onpage-icon-cs.js:183:2
onScriptLoad @ adblock-onpage-icon-cs.js:172
(anonymous) @ adblock-onpage-icon-cs.js:183
2.06539643.chunk.js:1 Uncaught SyntaxError: Unexpected token '<'
main.d8599842.chunk.js:1 Uncaught SyntaxError: Unexpected token '<'
DevTools failed to load source map: Could not load content for chrome-extension://ibamclpibpnhmkaphhemfbljmenlpbch/content.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME
about:client:1          GET chrome-extension://adlpodnneegcnbophopdmhedicjbcgco/content/styles.css net::ERR_FILE_NOT_FOUND


В чем может быть проблема? До этого такой проблемы не было.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
ceeed, 2022-02-21
@ceeed

Resolved the issue. It was all about the homepage parameter in package.json. I just removed this setting and it worked. The new webpack somehow strangely works with the homepage parameter, trying to put bare html into the js, which is why the problem.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question