postgrator:迁移postgresql数据库时找不到 [英] postgrator: not found while migrating postgresql database

查看:62
本文介绍了postgrator:迁移postgresql数据库时找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

  $ heroku run npm run migration在⬢shelly-moth-73910上运行npm run migration ... up,run.3979(免费)>noteful-app-server@1.0.0迁移/app>postgrator --config postgrator-config.jssh:1:postgrator:未找到npm ERR!代码ELIFECYCLEnpm ERR!syscall产生npm ERR!文件shnpm ERR!errno ENOENTnpm ERR!noteful-app-server@1.0.0迁移:`postgrator --config postgrator-config.js`npm ERR!产生ENOENTnpm ERR!npm ERR!在noteful-app-server@1.0.0迁移脚本上失败.npm ERR!npm可能不是问题.上面可能还有其他日志记录输出.npm ERR!可以在以下位置找到此运行的完整日志:npm ERR!/app/.npm/_logs/2020-09-06T07_52_36_217Z-debug.log 

在回购协议上安装了

postgrator-cli版本4.0.0,运行 npm list postgrator-cli 告诉我.但是在我推送到heroku之后,好像postgrator不存在了. heroku运行npm install postgrator-cli 和其他此类命令不会更改,并且 heroku运行npm list postgrator-cli 返回:

  $ heroku运行npm列表postgrator-cli在⬢rocky-garden-73910上运行npm list postgrator-cli ...运行7024(免费)noteful-app-server@1.0.0/app`-(空) 

这是我的 postgrator-config.js

  require('dotenv').config();module.exports = {'migrationsDirectory':'migrations','驱动程序':'pg','connectionString':process.env.NODE_ENV ==='测试'?process.env.TEST_DATABASE_URL:process.env.DATABASE_URL,'ssl':!! process.env.SSL,}; 

Procfile包含 web:节点src/server.js

解决方案

我只是遇到了相同的错误.

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

>

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

然后,我在postgrator-cli 中运行了 npm,检查了我的 package.json ,发现它存在于我的依赖项中.我git添加,提交并推送到heroku,然后运行 heroku run npm run migration -它起作用了!

Error:

$ 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

postgrator-cli version 4.0.0 is installed on repo, running npm list postgrator-cli tells me that. But after I push to heroku it's as though postgrator doesn't exist. heroku run npm install postgrator-cli and other such commands don't change, and heroku run npm list postgrator-cli returns:

$ 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)

Here's my postgrator-config.js

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,
};

Procfile contains web: node src/server.js

解决方案

I just had the same error.

In my package.json I found that it was in my "devDependencies", not my "dependencies".

When I first installed it, I ran npm i postgrator-cli -D, making it a development dependency. When I tried installing it again without the -D it didn't do anything, so I deleted it from my package.json.

Then, I ran npm i postgrator-cli and checked my package.json and found that it was in my dependencies. I git added, committed, and pushed to heroku and then I ran heroku run npm run migrate - it worked!

这篇关于postgrator:迁移postgresql数据库时找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆