我用最新的版本,新的4.0创建了一个Strapi应用程序,我想把它部署到Heroku。为了做到这一点,我确实遵循了Strapi文档,就像在此页中解释的那样。现在我发现了一个我不明白的错误,我想这与postgres有关。这是错误
2021-12-18T15:26:26.658380+00:00 app[web.1]: [2021-12-18 15:26:26.656] debug: ⛔️ Server wasn't able to start properly.
2021-12-18T15:26:26.659122+00:00 app[web.1]: [2021-12-18 15:26:26.658] error: Unknow dialect undefined
2021-12-18T15:26:26.659123+00:00 app[web.1]: Error: Unknow dialect undefined
2021-12-18T15:26:26.659123+00:00 app[web.1]: at getDialectClass (/app/node_modules/@strapi/database/lib/dialects/index.js:12:13)
2021-12-18T15:26:26.659123+00:00 app[web.1]: at getDialect (/app/node_modules/@strapi/database/lib/dialects/index.js:19:23)
2021-12-18T15:26:26.659124+00:00 app[web.1]: at new Database (/app/node_modules/@strapi/database/lib/index.js:38:20)
2021-12-18T15:26:26.659124+00:00 app[web.1]: at Function.Database.init (/app/node_modules/@strapi/database/lib/index.js:84:33)
2021-12-18T15:26:26.659125+00:00 app[web.1]: at Strapi.bootstrap (/app/node_modules/@strapi/strapi/lib/Strapi.js:347:30)
2021-12-18T15:26:26.659125+00:00 app[web.1]: at Strapi.load (/app/node_modules/@strapi/strapi/lib/Strapi.js:410:16)
2021-12-18T15:26:26.659125+00:00 app[web.1]: at async Strapi.start (/app/node_modules/@strapi/strapi/lib/Strapi.js:161:9)除了执行我所链接的文档中所解释的内容之外,我只是在开发模式中使用UI添加了一些集合。我如何修正这个错误并将这个新的4.0版本的Strapi部署到Heroku?
发布于 2022-01-10 01:26:17
当我在本地连接pg时,我遇到了类似的问题,然后意识到我的连接配置是不正确的。当我用v4模板替换它时,它起了作用。
路径:config/database.js
module.exports = ({ env }) => ({
defaultConnection: "default",
connection: {
client: "postgres",
connection: {
host: env("DATABASE_HOST", "localhost"),
port: env.int("DATABASE_PORT", 5432),
database: env("DATABASE_NAME", "bank"),
username: env("DATABASE_USERNAME", "postgres"),
password: env("DATABASE_PASSWORD", "0000"),
schema: env("DATABASE_SCHEMA", "public"),
},
}
});至于Heorku,正如文章所建议的:
路径:config/env/production/database.js
const parse = require('pg-connection-string').parse;
const config = parse(process.env.DATABASE_URL);
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: config.host,
port: config.port,
database: config.database,
user: config.user,
password: config.password,
ssl: {
rejectUnauthorized: false
},
},
debug: false,
},
});PS:在推到heroku之前,一定要将pg-connection-string添加到依赖项中。
发布于 2022-01-06 05:43:56
getDialectClass -来自错误日志
const getDialectClass = client => {
switch (client) {
case 'postgres':
return require('./postgresql');
case 'mysql':
return require('./mysql');
case 'sqlite':
return require('./sqlite');
default:
throw new Error(`Unknow dialect ${client}`);
}
};客户端所在的地方- db.config.connection
因此,如果您一直在遵循以前的解决方案--其中谈到了连接、对象等(如下所示)
module.exports = ({ env }) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: config.host,
port: config.port,
database: config.database,
username: config.user,
password: config.password,
ssl: {
rejectUnauthorized: false,
},
},
options: {
ssl: true,
},
},
},
});db.config.connection将返回未定义的。&所以它会失败
发布于 2022-09-15 08:32:51
如果您在Strapi中使用类型记录,我们可能也会遇到这个问题,因为有一个影响Strapi类型记录功能的问题。
当我将Strapi从4.3.8降到4.3.2时,我可以解决这个问题。
https://stackoverflow.com/questions/70404776
复制相似问题