当我运行“键入<file_name> | heroku pg:psql”时,为什么会出现错误提示“ *或附近的语法错误”

时间:2018-12-04 01:16:05

标签: node.js postgresql heroku

每当我到达需要运行此命令type <file_name> | heroku pg:psql type db.js | heroku pg:psql HEROKU_POSTGRESQL_CYAN的步骤时,我都尝试将具有Postgres数据库的节点应用程序部署到Heroku。具体来说,我收到此错误:syntax error at or near *。 db.js是我的迁移文件,在运行命令之前,我先进入包含该文件的构建文件夹。 我在服务器文件夹中编写了es6代码,然后将其编译为es5到了一个构建文件夹中。 在下面找到我遇到的错误。

运行后出现错误消息:

type db.js | heroku pg:psql HEROKU_POSTGRESQL_CYAN
--> Connecting to postgresql-asymmetrical-70043
ERROR:  syntax error at or near "const"
LINE 4: const _pg = require('pg');
        ^
ERROR:  syntax error at or near "const"
LINE 1: const _dotenv = require('dotenv');
        ^
ERROR:  syntax error at or near "//"
LINE 1: // eslint-disable-next-line no-use-before-define
        ^
ERROR:  syntax error at or near "function"
LINE 1: function _interopRequireDefault(obj) { return obj && obj.__e...
        ^
ERROR:  syntax error at or near "}"
LINE 1: }
        ^
ERROR:  syntax error at or near "const"
LINE 1: const pool = new _pg.Pool({
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.on('connect', () => {
        ^
ERROR:  syntax error at or near "const"
LINE 2: const createOrderTable = function createOrderTable() {
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.query(queryText).then((res) => {
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const createUserTable = function createUserTable() {
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.query(queryText).then((res) => {
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const createMenuTable = function createMenuTable() {
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.query(queryText).then((res) => {
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const dropOrderTable = function dropOrderTable() {
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.query(queryText).then((res) => {
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const dropUserTable = function dropUserTable() {
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.query(queryText).then((res) => {
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const dropMenuTable = function dropMenuTable() {
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.query(queryText).then((res) => {
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const createAllTables = function createAllTables() {
        ^
ERROR:  syntax error at or near "createOrderTable"
LINE 1: createOrderTable();
        ^
ERROR:  syntax error at or near "createMenuTable"
LINE 1: createMenuTable();
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "const"
LINE 2: const dropAllTables = function dropAllTables() {
        ^
ERROR:  syntax error at or near "dropOrderTable"
LINE 1: dropOrderTable();
        ^
ERROR:  syntax error at or near "dropMenuTable"
LINE 1: dropMenuTable();
        ^
ERROR:  syntax error at or near "}"
LINE 1: };
        ^
ERROR:  syntax error at or near "pool"
LINE 1: pool.on('remove', () => {
        ^
ERROR:  syntax error at or near "module"
LINE 1: module.exports = {
        ^
ERROR:  syntax error at or near "require"
LINE 1: require('make-runnable');
        ^

尽管我的应用是通过应用的Heroku URL发布的,但api的Postgres表行还是空的。

{
rows: [ ],
rowCount: 0
}

0 个答案:

没有答案