使用Postgres部署Strapi CMS时出现Heroku应用程序错误



我一直试图将我的Stapi CMS部署到Heroku,但我一直遇到错误。它成功构建并部署,但当我访问URL时,它只显示"应用程序错误"。

以下是构建日志:

-----> Node.js app detected

-----> Creating runtime environment

NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false

-----> Installing binaries
engines.node (package.json):  >=10.0.0
engines.npm (package.json):   >=6.0.0

Resolving node version >=10.0.0...
Downloading and installing node 15.3.0...
Bootstrapping npm >=6.0.0 (replacing 7.0.14)...
npm >=6.0.0 installed

-----> Installing dependencies
Installing node modules

> @fortawesome/fontawesome-common-types@0.2.32 postinstall /tmp/build_df2cd10e/node_modules/@fortawesome/fontawesome-common-types
> node attribution.js

Font Awesome Free 0.2.32 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


> @fortawesome/free-solid-svg-icons@5.15.1 postinstall /tmp/build_df2cd10e/node_modules/@fortawesome/free-solid-svg-icons
> node attribution.js

Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


> @fortawesome/free-regular-svg-icons@5.15.1 postinstall /tmp/build_df2cd10e/node_modules/@fortawesome/free-regular-svg-icons
> node attribution.js

Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


> @fortawesome/fontawesome-svg-core@1.2.32 postinstall /tmp/build_df2cd10e/node_modules/@fortawesome/fontawesome-svg-core
> node attribution.js

Font Awesome Free 1.2.32 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


> @fortawesome/fontawesome-free@5.15.1 postinstall /tmp/build_df2cd10e/node_modules/@fortawesome/fontawesome-free
> node attribution.js

Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


> sharp@0.26.0 install /tmp/build_df2cd10e/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.0/libvips-8.10.0-linux-x64.tar.br

> core-js@3.6.5 postinstall /tmp/build_df2cd10e/node_modules/fbjs/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> fsevents@1.2.13 install /tmp/build_df2cd10e/node_modules/webpack-dev-server/node_modules/fsevents
> node install.js


Skipping 'fsevents' build as platform linux is not supported

> fsevents@1.2.13 install /tmp/build_df2cd10e/node_modules/watchpack-chokidar2/node_modules/fsevents
> node install.js


Skipping 'fsevents' build as platform linux is not supported

> @fortawesome/free-brands-svg-icons@5.15.1 postinstall /tmp/build_df2cd10e/node_modules/@fortawesome/free-brands-svg-icons
> node attribution.js

Font Awesome Free 5.15.1 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)


> core-js@2.6.11 postinstall /tmp/build_df2cd10e/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> strapi@3.2.1 postinstall /tmp/build_df2cd10e/node_modules/strapi
> node lib/utils/success.js


> sqlite3@5.0.0 install /tmp/build_df2cd10e/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

[sqlite3] Success: "/tmp/build_df2cd10e/node_modules/sqlite3/lib/binding/napi-v3-linux-x64/node_sqlite3.node" is installed via remote
added 1562 packages in 39.888s

-----> Build
Running build

> server@0.1.0 build /tmp/build_df2cd10e
> strapi build

Building your admin UI with production configuration ...
ℹ Compiling Webpack
✔ Webpack: Compiled successfully in 1.53m

-----> Caching build
- node_modules

-----> Pruning devDependencies
removed 22 packages and audited 1542 packages in 11.993s

70 packages are looking for funding
run `npm fund` for details

found 0 vulnerabilities


-----> Build succeeded!
-----> Discovering process types
Procfile declares types     -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 149.6M
-----> Launching...
Released v6
https://ghost-lifestyle-ecommerce.herokuapp.com/ deployed to Heroku

错误日志:

2020-11-29T10:19:03.786723+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-29T10:19:03.796351+00:00 app[web.1]: 
2020-11-29T10:19:03.796542+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-29T10:19:03.796694+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-11-29T10_19_03_788Z-debug.log
2020-11-29T10:19:03.847200+00:00 heroku[web.1]: Process exited with status 1
2020-11-29T10:19:03.886169+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-29T10:19:03.890353+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-29T10:19:08.000000+00:00 app[api]: Build succeeded
2020-11-29T10:19:26.024886+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-29T10:19:29.057541+00:00 app[web.1]: 
2020-11-29T10:19:29.057564+00:00 app[web.1]: > server@0.1.0 start /app
2020-11-29T10:19:29.057564+00:00 app[web.1]: > strapi start
2020-11-29T10:19:29.057565+00:00 app[web.1]: 
2020-11-29T10:19:32.771015+00:00 app[web.1]: [2020-11-29T10:19:32.770Z] debug ⛔️ Server wasn't able to start properly.
2020-11-29T10:19:32.773653+00:00 app[web.1]: [2020-11-29T10:19:32.773Z] error error: null value in column "id" violates not-null constraint
2020-11-29T10:19:32.773655+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:278:15)
2020-11-29T10:19:32.773655+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2020-11-29T10:19:32.773656+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2020-11-29T10:19:32.773656+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:10:42)
2020-11-29T10:19:32.773659+00:00 app[web.1]: at Socket.emit (node:events:376:20)
2020-11-29T10:19:32.773660+00:00 app[web.1]: at addChunk (node:internal/streams/readable:304:12)
2020-11-29T10:19:32.773661+00:00 app[web.1]: at readableAddChunk (node:internal/streams/readable:279:9)
2020-11-29T10:19:32.773661+00:00 app[web.1]: at Socket.Readable.push (node:internal/streams/readable:218:10)
2020-11-29T10:19:32.773661+00:00 app[web.1]: at TCP.onStreamRead (node:internal/stream_base_commons:192:23)
2020-11-29T10:19:32.795758+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-29T10:19:32.796257+00:00 app[web.1]: npm ERR! errno 1
2020-11-29T10:19:32.803913+00:00 app[web.1]: npm ERR! server@0.1.0 start: `strapi start`
2020-11-29T10:19:32.804152+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-29T10:19:32.804381+00:00 app[web.1]: npm ERR!
2020-11-29T10:19:32.804585+00:00 app[web.1]: npm ERR! Failed at the server@0.1.0 start script.
2020-11-29T10:19:32.804756+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-29T10:19:32.811241+00:00 app[web.1]: 
2020-11-29T10:19:32.811477+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-29T10:19:32.811622+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-11-29T10_19_32_805Z-debug.log
2020-11-29T10:19:32.874877+00:00 heroku[web.1]: Process exited with status 1
2020-11-29T10:19:32.917828+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-29T10:19:53.991477+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ghost-lifestyle-ecommerce.herokuapp.com request_id=69f1a34f-9429-4f0b-bdf8-ddddf59a5f77 fwd="101.174.44.54" dyno= connect= service= status=503 bytes= protocol=https
2020-11-29T10:19:54.458022+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ghost-lifestyle-ecommerce.herokuapp.com request_id=6c735d09-ceaf-489f-95dc-ba363dfd4445 fwd="101.174.44.54" dyno= connect= service= status=503 bytes= protocol=https
2020-11-29T10:36:05.826739+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ghost-lifestyle-ecommerce.herokuapp.com request_id=bd172ddf-258a-411e-afbb-4f2c0c3c7898 fwd="101.174.44.54" dyno= connect= service= status=503 bytes= protocol=https
2020-11-29T10:36:06.195989+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ghost-lifestyle-ecommerce.herokuapp.com request_id=0b0acc34-0713-4050-8b9a-3c0f89f824a8 fwd="101.174.44.54" dyno= connect= service= status=503 bytes= protocol=https
2020-11-29T10:44:26.490521+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-29T10:44:43.033805+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-29T10:44:45.678896+00:00 app[web.1]: 
2020-11-29T10:44:45.678910+00:00 app[web.1]: > server@0.1.0 start /app
2020-11-29T10:44:45.678911+00:00 app[web.1]: > strapi start
2020-11-29T10:44:45.678911+00:00 app[web.1]: 
2020-11-29T10:44:48.252950+00:00 app[web.1]: [2020-11-29T10:44:48.252Z] debug ⛔️ Server wasn't able to start properly.
2020-11-29T10:44:48.254087+00:00 app[web.1]: [2020-11-29T10:44:48.254Z] error error: null value in column "id" violates not-null constraint
2020-11-29T10:44:48.254088+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:278:15)
2020-11-29T10:44:48.254088+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2020-11-29T10:44:48.254089+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2020-11-29T10:44:48.254090+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:10:42)
2020-11-29T10:44:48.254090+00:00 app[web.1]: at Socket.emit (node:events:376:20)
2020-11-29T10:44:48.254091+00:00 app[web.1]: at addChunk (node:internal/streams/readable:304:12)
2020-11-29T10:44:48.254092+00:00 app[web.1]: at readableAddChunk (node:internal/streams/readable:279:9)
2020-11-29T10:44:48.254092+00:00 app[web.1]: at Socket.Readable.push (node:internal/streams/readable:218:10)
2020-11-29T10:44:48.254093+00:00 app[web.1]: at TCP.onStreamRead (node:internal/stream_base_commons:192:23)
2020-11-29T10:44:48.269283+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-29T10:44:48.269565+00:00 app[web.1]: npm ERR! errno 1
2020-11-29T10:44:48.273987+00:00 app[web.1]: npm ERR! server@0.1.0 start: `strapi start`
2020-11-29T10:44:48.274132+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-29T10:44:48.274294+00:00 app[web.1]: npm ERR!
2020-11-29T10:44:48.274491+00:00 app[web.1]: npm ERR! Failed at the server@0.1.0 start script.
2020-11-29T10:44:48.274520+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-29T10:44:48.283421+00:00 app[web.1]: 
2020-11-29T10:44:48.283572+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-29T10:44:48.283639+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-11-29T10_44_48_275Z-debug.log
2020-11-29T10:44:48.326804+00:00 heroku[web.1]: Process exited with status 1
2020-11-29T10:44:48.366865+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-29T10:50:41.286347+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ghost-lifestyle-ecommerce.herokuapp.com request_id=c118bb50-72c2-4946-82d1-1ac85cf4faed fwd="101.174.44.54" dyno= connect= service= status=503 bytes= protocol=https
2020-11-29T10:50:41.661063+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ghost-lifestyle-ecommerce.herokuapp.com request_id=497bb654-a07e-49a6-8863-88c80ca41a27 fwd="101.174.44.54" dyno= connect= service= status=503 bytes= protocol=https
2020-11-29T11:39:39.766921+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-29T11:39:57.294612+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-29T11:39:59.486582+00:00 app[web.1]: 
2020-11-29T11:39:59.486597+00:00 app[web.1]: > server@0.1.0 start /app
2020-11-29T11:39:59.486598+00:00 app[web.1]: > strapi start
2020-11-29T11:39:59.486598+00:00 app[web.1]: 
2020-11-29T11:40:02.480742+00:00 app[web.1]: [2020-11-29T11:40:02.480Z] debug ⛔️ Server wasn't able to start properly.
2020-11-29T11:40:02.482309+00:00 app[web.1]: [2020-11-29T11:40:02.482Z] error error: null value in column "id" violates not-null constraint
2020-11-29T11:40:02.482310+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:278:15)
2020-11-29T11:40:02.482310+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2020-11-29T11:40:02.482310+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2020-11-29T11:40:02.482311+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:10:42)
2020-11-29T11:40:02.482312+00:00 app[web.1]: at Socket.emit (node:events:376:20)
2020-11-29T11:40:02.482313+00:00 app[web.1]: at addChunk (node:internal/streams/readable:304:12)
2020-11-29T11:40:02.482313+00:00 app[web.1]: at readableAddChunk (node:internal/streams/readable:279:9)
2020-11-29T11:40:02.482313+00:00 app[web.1]: at Socket.Readable.push (node:internal/streams/readable:218:10)
2020-11-29T11:40:02.482314+00:00 app[web.1]: at TCP.onStreamRead (node:internal/stream_base_commons:192:23)
2020-11-29T11:40:02.506521+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-29T11:40:02.506936+00:00 app[web.1]: npm ERR! errno 1
2020-11-29T11:40:02.513481+00:00 app[web.1]: npm ERR! server@0.1.0 start: `strapi start`
2020-11-29T11:40:02.513624+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-29T11:40:02.513780+00:00 app[web.1]: npm ERR!
2020-11-29T11:40:02.513904+00:00 app[web.1]: npm ERR! Failed at the server@0.1.0 start script.
2020-11-29T11:40:02.514025+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-29T11:40:02.524049+00:00 app[web.1]: 
2020-11-29T11:40:02.524269+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-29T11:40:02.524394+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-11-29T11_40_02_514Z-debug.log
2020-11-29T11:40:02.570419+00:00 heroku[web.1]: Process exited with status 1
2020-11-29T11:40:02.617901+00:00 heroku[web.1]: State changed from starting to crashed

我在Stack Overflow上看到过一些类似的问题,但我无法从中找到解决方案。如有任何帮助,我们将不胜感激。

设法弄清楚了这一点。我认为这是我使用的Strapi版本和pg依赖性的问题。我刚刚用最新的稳定版本重新安装了Strapi,它解决了这个问题。

最新更新