postgrator:迁移postgresql数据库时找不到

问题描述

错误

<input type="text" id="txt" onkeyup="fnSingleValue(this)"/>
回购中已安装

postgrator-cli版本4.0.0,运行$ heroku run npm run migrate Running npm run migrate on ⬢ shelly-moth-73910... up,run.3979 (Free) > noteful-app-server@1.0.0 migrate /app > postgrator --config postgrator-config.js sh: 1: postgrator: not found npm ERR! code ELIFECYCLE npm ERR! syscall spawn npm ERR! file sh npm ERR! errno ENOENT npm ERR! noteful-app-server@1.0.0 migrate: `postgrator --config postgrator-config.js` npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the noteful-app-server@1.0.0 migrate 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! /app/.npm/_logs/2020-09-06T07_52_36_217Z-debug.log 告诉我。但是在我推送到heroku之后,好像postgrator不存在了。 npm list postgrator-cli和其他此类命令不变,heroku run npm install postgrator-cli返回:

heroku run npm list postgrator-cli

这是我的$ heroku run npm list postgrator-cli Running npm list postgrator-cli on ⬢ rocky-garden-73910... up,run.7024 (Free) noteful-app-server@1.0.0 /app `-- (empty)

postgrator-config.js

procfile包含require('dotenv').config(); module.exports = { 'migrationsDirectory': 'migrations','driver': 'pg','connectionString': process.env.NODE_ENV === 'test' ? process.env.TEST_DATABASE_URL : process.env.DATABASE_URL,'ssl': !!process.env.SSL,};

解决方法

我有同样的错误。

在我的package.json中,我发现它在我的"devDependencies"中,而不是我的"dependencies"

当我第一次安装它时,我运行了npm i postgrator-cli -D,使其成为开发依赖项。当我尝试不使用-D再次安装它时,它什么也没做,所以我从我的 package.json中删除了它。

然后,我运行npm i postgrator-cli并检查了package.json,发现它在我的dependencies中。我git添加,提交并推送到heroku,然后运行heroku run npm run migrate-它起作用了!