0
我已經制作了一個使用create-react-app
的web應用程序,它工作正常,我通常使用npm start
運行它,但現在我必須部署它並使其與nodejs forever
模塊配合使用。nodejs啓動react-app客戶端
如果我這樣做node src/index.js
它會給一個語法錯誤並解決這個問題我以前通天transpile es6
到es5
,但再次導入CSS文件時,我得到了以下語法錯誤:
/client/src/stylesheets/menu.css:1
(function (exports, require, module, __filename, __dirname) { header {
^
SyntaxError: Unexpected token {
這是我package.json
文件:
{
"dependencies": {
"async": "^2.5.0",
"axios": "^0.16.2",
"classnames": "^2.2.5",
"date-diff": "^0.1.3",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.4",
"react": "^15.6.1",
"react-bootstrap": "^0.31.2",
"react-bootstrap-table": "^4.0.2",
"react-dom": "^15.6.1",
"react-redux": "^5.0.6",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.0.12",
"react-select": "^1.0.0-rc.5",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"shortid": "^2.2.8",
"validator": "^8.1.0"
},
"scripts": {
"start": "react-scripts-with-stylus start src/stylesheets/menu.styl",
"build": "react-scripts-with-stylus build src/stylesheets/menu.styl",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8081",
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"create-react-app-stylus": "^1.1.1",
"webpack": "^3.5.5"
}
}
如果您需要部署它,您應該進行構建,而不是直接運行您的應用程序。 – Shota
我如何構建?這是我的第一個反應應用程序,任何信息都會幫助我很多......我試圖將它部署到數字海洋 – Valip
run'npm run build',它會將生成文件生成到一個新文件夾中。 – Shota