【问题标题】:npm run dev can't connect to the client servernpm run dev 无法连接到客户端服务器
【发布时间】:2022-02-01 10:00:10
【问题描述】:

我是 npm 和 javascript 的新手,但我正在尝试使用现有的 npm 项目在本地运行和测试它。我使用命令npm run dev 同时激活服务和客户端脚本。为了能够连接到服务器 url,我使用了上面命令中的律师建议的 http://localhost:5200/,我从浏览器中收到以下消息“{“hi”:“there”}。我希望这个命令能让我进入为这个项目创建和构建的网站。我收到警告但没有错误。这些警告是否会导致连接问题?如何解决此问题并连接到客户端服务器?

非常感谢任何帮助或解决此问题的建议。

这是我运行命令时的顾问输出:

> backendserver@1.0.0 dev
> concurrently "npm run server" "npm run client"
 
[1]
[1] > backendserver@1.0.0 client
[1] > npm run start --prefix client
[1]
[0]
[0] > backendserver@1.0.0 server
[0] > nodemon index.js
[0]
[1]
[1] > client@0.1.0 start
[1] > react-scripts start
[1]
[0] [nodemon] 1.19.4
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching dir(s): *.*
[0] [nodemon] watching extensions: js,mjs,json
[0] [nodemon] starting `node index.js`
[0] devUser
[0] App listening on port 5200
[1] Attempting to bind to HOST environment variable: x86_64-apple-darwin13.4.0
[1] If this was unintentional, check that you haven't mistakenly set it in your shell.
[1]
[1] [HPM] Proxy created: /api/*  ->  http://localhost:5200/
[1] Compiled with warnings.
[1]
[1] ./src/components/searches/QueryHookForm_v3.js
[1]   Line 16:9:    'options1' is assigned a value but never used         no-unused-vars
[1]   Line 22:9:    'options2' is assigned a value but never used         no-unused-vars
[1]   Line 222:25:  'register' is assigned a value but never used         no-unused-vars
[1]   Line 373:7:   'mapStateToProps' is assigned a value but never used  no-unused-vars
[1]
[1] ./src/components/plot/TestPlot_v12.js
[1]   Line 1:17:  'useState' is defined but never used               no-unused-vars
[1]   Line 1:27:  'useEffect' is defined but never used              no-unused-vars
[1]   Line 1:38:  'useRef' is defined but never used                 no-unused-vars
[1]   Line 31:7:  'geneAccessor' is assigned a value but never used  no-unused-vars
[1]   Line 54:9:  'inputData2' is assigned a value but never used    no-unused-vars
[1]
[1] ./src/components/dataset/DataSetDownload_v2.js
[1]   Line 20:67:   Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]   Line 23:107:  Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]   Line 26:46:   Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]
[1] ./src/components/tables/ReactTableContainer_v3.js
[1]   Line 26:25:   Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener                                                                                                                                                                                                                                             react/jsx-no-target-blank
[1]   Line 43:21:   The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
[1]   Line 93:21:   The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
[1]   Line 153:21:  The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
[1]
[1] ./src/components/landing/UseCases/CollapsibleComponent/Panel.js
[1]   Line 27:26:  Expected '===' and instead saw '=='  eqeqeq
[1]   Line 34:26:  Expected '===' and instead saw '=='  eqeqeq
[1]
[1] ./src/components/header/Header_v3.js
[1]   Line 32:33:  Expected '===' and instead saw '=='  eqeqeq
[1]
[1] ./src/components/plot/OptionsGroup/OptionsGroup.js
[1]   Line 3:10:  'fetchGeneSummary' is defined but never used                                                                                               no-unused-vars
[1]   Line 38:7:  React Hook useCallback has missing dependencies: 'option1.name' and 'setGroupOptions'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
[1]   Line 57:7:  React Hook useCallback has missing dependencies: 'option2.name' and 'setGroupOptions'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
[1]
[1] ./src/components/footer/Footer.js
[1]   Line 40:22:  Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]
[1] ./src/components/App.js
[1]   Line 4:8:  'ReactGA' is defined but never used  no-unused-vars
[1]
[1] ./src/components/documentation/Documentation_v3.js
[1]   Line 50:75:    Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]   Line 641:88:   Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]   Line 645:57:   Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]   Line 662:103:  Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener  react/jsx-no-target-blank
[1]
[1] ./src/components/plot/PiePlot_v12.js
[1]   Line 6:10:    'elementType' is defined but never used                                                                                                                                                                                                                                                       no-unused-vars
[1]   Line 15:25:   'selectedFilters' is assigned a value but never used                                                                                                                                                                                                                                          no-unused-vars
[1]   Line 15:42:   'setSelectedFilters' is assigned a value but never used                                                                                                                                                                                                                                       no-unused-vars
[1]   Line 28:45:   Expected '===' and instead saw '=='                                                                                                                                                                                                                                                           eqeqeq
[1]   Line 28:61:   Unexpected mix of '&' and '|'                                                                                                                                                                                                                                                                 no-mixed-operators
[1]   Line 28:67:   Unexpected mix of '&' and '|'                                                                                                                                                                                                                                                                 no-mixed-operators
  Line 310:49:  Unexpected string concatenation of literals                                                                                                                                                                                                                                                   no-useless-concat
[1]   Line 332:49:  Unexpected string concatenation of literals                                                                                                                                                                                                                                                   no-useless-concat
[1]   Line 354:16:  'x_coord' is assigned a value but never used                                                                                                                                                                                                                                                  no-unused-vars
[1]   Line 381:5:   React Hook useEffect has missing dependencies: 'colors', 'createArc', 'createArcOver', 'createOuter2Arc', 'createOuterArc', 'createPie', 'filteredData', 'format', 'props.height', 'props.keyID', 'props.outerRadius', and 'props.width'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
[1]
[1] ./src/actions/index.js
[1]   Line 6:10:  'FETCH_WEATHER' is defined but never used  no-unused-vars
[1]
[1] ./src/components/studies/ReactBootstrapTableForStudies.js
[1]   Line 73:15:  'defaultSorted' is assigned a value but never used  no-unused-vars
[1]
[1] ./src/components/fileupload/FileUpload_v2.js
[1]   Line 75:13:  'payload' is assigned a value but never used          no-unused-vars
[1]   Line 151:7:  'setFieldTouched' is assigned a value but never used  no-unused-vars
[1]
[1] Search for the keywords to learn more about each warning.
[1] To ignore, add // eslint-disable-next-line to the line before.
[1]

【问题讨论】:

标签: javascript npm package.json


【解决方案1】:

5200 是后端的端口,前端必须在不同的端口上

通常是 3000 端口,或者在 .env 文件中配置

尝试使用npm run client 来检查前端

【讨论】:

  • 我尝试了命令 npm run client。它不起作用,还使用 ​​5200 端口。
猜你喜欢
  • 2019-08-03
  • 2012-10-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多