【问题标题】:Error While Deploying React application on server在服务器上部署 React 应用程序时出错
【发布时间】:2019-08-21 02:00:54
【问题描述】:

在服务器上运行应用程序时出现错误 它在本地正常工作我只需输入运行(npm start)并在本地完美运行。 但是我在服务器上做的同样的事情我得到了下面给出的错误。 请有人帮帮我。

SyntaxError: Unexpected end of input
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:646:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
    at Module.require (internal/modules/cjs/loader.js:626:17)
    at require (internal/modules/cjs/helpers.js:20:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chakde11@1.0.0 build-css: `node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chakde11@1.0.0 build-css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-03-30T06_54_54_535Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chakde11@1.0.0 watch-css: `npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chakde11@1.0.0 watch-css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-03-30T06_54_54_566Z-debug.log
ERROR: "watch-css" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chakde11@1.0.0 start: `npm-run-all -p watch-css start-js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chakde11@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-03-30T06_54_54_800Z-debug.log

{ “名称”:“chakde11”, “版本”:“1.0.0”, “私人”:假, "主页": "http://chakde11.com/", “依赖”:{ “引导程序”:“4.1.1”, "chart.js": "^2.7.2", "类名": "^2.2.6", "d3-geo": "^1.10.0", "日期格式": "^3.0.3", “伪造者”:“^4.1.0”, "jsx": "^0.9.89", "npm": "^6.9.0", "package.json": "^2.0.1", “道具类型”:“^15.6.2”, “反应”:“^0.14.9”, "react-chartjs-2": "^2.7.2", “反应组件查询”:“^2.3.0”, “现在反应倒计时”:“^2.1.0”, “反应倒计时到未来日期”:“0.0.3”, "react-d3-map": "^0.8.3", “反应域”:“^16.4.1”, “反应-ga”:“^2.5.3”, “反应图标”:“^2.2.7”, “反应无限日历”:“^2.3.1”, “反应通知系统”:“^0.2.17”, “反应路由器”:“^4.3.1”, "react-router-dom": "^4.3.1", “反应简单地图”:“^0.12.1”, “反应尺寸”:“^2.5.2”, “反应过渡组”:“^2.3.1”, “reactjs-countdown”:“0.0.8”, "reactstrap": "^6.1.0", “胜利”:“^0.27.1” }, “开发依赖”:{ "gh-pages": "^1.2.0", “node-sass-chokidar”:“^1.3.4”, "npm-run-all": "^4.1.3", “反应脚本”:“1.1.4”, "服务": "^9.1.0", "stylelint": "^9.3.0", "stylelint-config-recommended-scss": "^3.2.0", "stylelint-config-standard": "^18.2.0", "stylelint-order": "^0.8.1", “stylelint-scss”:“^3.1.3” }, “脚本”:{ "build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/", "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive", "start-js": "react-scripts 启动", "start": "npm-run-all -p watch-css start-js", "build": "npm run build-css && react-scripts build", “服务”:“服务 -s 构建”, “部署”:“gh-pages -d 构建”, "test": "react-scripts 测试 --env=jsdom", “弹出”:“反应脚本弹出” } }

【问题讨论】:

  • 你的构建脚本是什么?您是否将静态站点部署到服务器或只是运行节点脚本?你运行“npm install”吗?
  • 我运行 npm install,然后在域文件夹中运行 npm start。是的,我正在将静态站点部署到服务器,我需要更改任何文件或代码吗?我更改了主页:package.json 文件中的“MyURL”。
  • 您可能需要发布您的 package.json 文件。
  • 是的,我刚刚在问题下方添加了 package.json 代码
  • @MattYao 我已经发布了我的 package.json。

标签: reactjs deployment windows-server npm-start run-script


【解决方案1】:

我建议您检查您的 package.json 文件“启动”脚本,或许将命令更改为:

"start": "NODE_PATH=./src npm-run-all -p watch-css start-js",

我发现了和你一样的问题:https://github.com/creativetimofficial/ct-material-dashboard-pro-react/issues/69

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-07
    • 2020-04-26
    • 1970-01-01
    • 2019-03-06
    • 2022-06-29
    • 2016-03-30
    • 1970-01-01
    • 2020-07-04
    相关资源
    最近更新 更多