错误:ENOENT:没有这样的文件或目录,scandir'/ app / migrations'

时间:2019-01-13 04:30:49

标签: node.js heroku knex.js

尝试运行

heroku run knex migrate:latest

在heroku上使用node和pg设置数据库,我得到以下错误

Error: ENOENT: no such file or directory, scandir '/app/migrations'

knexfile.js

module.exports = {
  development: {
    client: 'sqlite3',
    connection: {
      filename: './db/dnd.sqlite3'
    },
    useNullAsDefault: true,
    migrations: {
      directory: './db/migrations'
    },
    seeds: {
      directory: './db/seeds'
    }
  },
  production: {
    client: 'pg',
    connection: {
      database: 'my_db',
      user: process.env.USER,
      password: process.env.PASSWORD,
      DATABASE_URL: process.env.DATABASE_URL,
    }
  }
};

这是我的package.json文件的副本

{
  "name": "backend",
  "version": "1.0.0",
  "description": "backend",
  "main": "index.js",
  "scripts": {
    "test": "(knex migrate:rollback && knex migrate:latest && knex seed:run) && NODE_ENV=test jest --verbose --watch",
    "start": "nodemon server.js",
    "re": "knex migrate:rollback && knex migrate:latest && knex seed:run"
  },
  "keywords": [],
  "author": "my-name",
  "license": "MIT",
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "cors": "^2.8.4",
    "express": "^4.16.3",
    "helmet": "^3.14.0",
    "jsonwebtoken": "^8.3.0",
    "knex": "^0.15.2",
    "morgan": "^1.9.1",
    "pg": "^7.8.0",
    "renderer": "^0.1.5",
    "sqlite3": "^4.0.3"
  },
  "devDependencies": {
    "coveralls": "^3.0.2",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.6.0",
    "jest": "^23.6.0",
    "mocha": "^5.2.0",
    "nodemon": "^1.18.5",
    "supertest": "^3.3.0"
  },
  "jest": {
    "testEnvironment": "node",
    "testPathIgnorePatterns": [
      "/node_modules/",
      "<rootDir>/notes/src/__tests__/"
    ]
  }
}

有人在工作pg和node并尝试部署到heroku之前遇到了此错误吗?我已经尝试了很多方法,但目前似乎有些困难。不知道该怎么办。

1 个答案:

答案 0 :(得分:0)

如果您的迁移文件夹为空,则不会将其推送到Heroku,因此您可以做两件事。

1)使用heroku run bash --app'your-app-name'手动创建文件夹

2)在迁移文件夹中,创建一个空文件,提交并推送到Heroku