我試圖幾個小時,現在都留下不知道......也許你有一些:-)Herkoku節點部署與子文件夾
我用react-starter-kit作爲我的反應,應用程序和gitlab爲我的倉庫。我已啓用gitlab-ci
部署並將我的應用程序發佈到heroku。
那麼好吧,gitlab-ci
作品... 耶
但反應-初學者工具包使用/build
文件夾,爲所有的資產和精縮等應用。
我怎麼能通過gitlab-ci在heroku上獲得一個可運行的應用程序? 我已經添加了Procfile與此內容: web: node ./build/server.js
Heroku的日誌輸出如下:
2017-01-02T16:57:54.655686+00:00 heroku[web.1]: State changed from crashed to starting
2017-01-02T16:57:58.721166+00:00 heroku[web.1]: Starting process with command `node ./build/server.js`
2017-01-02T16:58:00.987643+00:00 heroku[web.1]: Process exited with status 1
2017-01-02T16:58:00.995852+00:00 heroku[web.1]: State changed from starting to crashed
2017-01-02T16:58:00.997060+00:00 heroku[web.1]: State changed from crashed to starting
2017-01-02T16:58:00.833548+00:00 app[web.1]: module.js:471
2017-01-02T16:58:00.833561+00:00 app[web.1]: throw err;
2017-01-02T16:58:00.833562+00:00 app[web.1]: ^
2017-01-02T16:58:00.833563+00:00 app[web.1]:
2017-01-02T16:58:00.833564+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2017-01-02T16:58:00.833565+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-01-02T16:58:00.833566+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-01-02T16:58:00.833567+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-01-02T16:58:00.833567+00:00 app[web.1]: at run (bootstrap_node.js:394:7)
2017-01-02T16:58:00.833568+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-01-02T16:58:00.833569+00:00 app[web.1]: at bootstrap_node.js:509:3
2017-01-02T16:58:07.230342+00:00 heroku[web.1]: Starting process with command `node ./build/server.js`
2017-01-02T16:58:10.416437+00:00 heroku[web.1]: State changed from starting to crashed
2017-01-02T16:58:10.398239+00:00 heroku[web.1]: Process exited with status 1
2017-01-02T16:58:10.271567+00:00 app[web.1]: module.js:471
2017-01-02T16:58:10.271583+00:00 app[web.1]: throw err;
2017-01-02T16:58:10.271584+00:00 app[web.1]: ^
2017-01-02T16:58:10.271584+00:00 app[web.1]:
2017-01-02T16:58:10.271585+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2017-01-02T16:58:10.271586+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-01-02T16:58:10.271586+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-01-02T16:58:10.271587+00:00 app[web.1]: at Module.runMain (module.js:604:10)
2017-01-02T16:58:10.271588+00:00 app[web.1]: at run (bootstrap_node.js:394:7)
2017-01-02T16:58:10.271588+00:00 app[web.1]: at startup (bootstrap_node.js:149:9)
2017-01-02T16:58:10.271588+00:00 app[web.1]: at bootstrap_node.js:509:3
要完成所有信息,我gitlab慈內容:
image: node:latest
stages:
- deploy
before_script:
- npm install
deploy:
stage: deploy
only:
- master
script:
- npm run build -- --release
- apt-get update -yq
- apt-get install ruby-dev rubygems -y
- gem install dpl
- dpl --provider=heroku --app=nice-app --api-key=$HEROKU_API_KEY
請幫幫我!謝謝!
UPDATE:
我的文件夾結構如下:
根的package.json的├── /build/
│ ├── /content/
│ ├── /public/
│ ├── /assets.js
│ ├── /package.json
│ ├── /server.js
├── /docs/
├── /node_modules/
├── /public/
├── /src/
│ ├── /components/
│ ├── /core/
│ ├── /data/
│ ├── /routes/
│ ├── /client.js
│ ├── /config.js
│ └── /server.js
├── /test/
├── /tools/
└── package.json
內容是這樣的:
{
"private": true,
"engines": {
"node": ">=6.5",
"npm": ">=3.10"
},
"dependencies": {
...
},
"devDependencies": {
...
},
"babel": {
"presets": [
"react",
"node5",
"stage-0"
],
"env": {
"test": {
"plugins": [
"rewire"
]
}
}
},
"eslintConfig": {
"parser": "babel-eslint",
"extends": "airbnb",
"globals": {
"__DEV__": true
},
"env": {
"browser": true
},
"rules": {
"arrow-parens": "off",
"generator-star-spacing": "off",
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"react/forbid-prop-types": "off",
"react/jsx-filename-extension": "off",
"react/no-danger": "off",
"react/no-unused-prop-types": "off"
}
},
"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
"string-quotes": "single",
"property-no-unknown": [
true,
{
"ignoreProperties": [
"composes"
]
}
],
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": [
"global",
"local"
]
}
]
}
},
"scripts": {
"lint:js": "eslint src tools",
"lint:css": "stylelint \"src/**/*.{css,less,scss,sss}\"",
"lint": "npm run lint:js && npm run lint:css",
"test": "mocha \"src/**/*.test.js\" --require test/setup.js --compilers js:babel-register",
"test:watch": "npm run test -- --reporter min --watch",
"clean": "babel-node tools/run clean",
"copy": "babel-node tools/run copy",
"bundle": "babel-node tools/run bundle",
"build": "babel-node tools/run build",
"deploy": "babel-node tools/run deploy",
"render": "babel-node tools/run render",
"start": "babel-node tools/run start"
}
}
,並在build文件夾中的package.json看起來像這樣:
{
"private": true,
"engines": {
"node": ">=6.5",
"npm": ">=3.10"
},
"dependencies": {
...
},
"scripts": {
"start": "node server.js"
}
}
你可以分享你的文件夾結構和你的package.json嗎? –
我已將您的請求數據更新爲我的帖子。希望它提前幫助和感謝。 – cqueiser