错误:ENOENT:没有这样的文件或目录,stat \'/ app / dist / client / build / index.js \''

时间:2019-10-27 10:34:58

标签: node.js typescript heroku

由于尚未找到解决方案,我真的需要帮助。

2019-10-28T15:48:14.987114+00:00 heroku[router]: sock=backend at=error code=H18 desc="Server Request Interrupted" method=GET path="/todos" host=apipracticecoding.herokuapp.com request_id=38515e4f-490e-4bc9-99ef-7d80280aeec5 fwd="41.234.192.84" dyno=web.1 connect=1ms service=18ms status=503 bytes= protocol=https
2019-10-28T15:48:14.986317+00:00 app[web.1]: [2019-10-28T15:48:14.972] [INFO ] [TSED] - { reqId: '4',
2019-10-28T15:48:14.98634+00:00 app[web.1]: method: 'GET',
2019-10-28T15:48:14.986342+00:00 app[web.1]: url: '/todos',
2019-10-28T15:48:14.986344+00:00 app[web.1]: duration: 0,
2019-10-28T15:48:14.986347+00:00 app[web.1]: time: 2019-10-28T15:48:14.972Z,
2019-10-28T15:48:14.986349+00:00 app[web.1]: event: 'request.start' }
2019-10-28T15:48:14.986699+00:00 app[web.1]: [2019-10-28T15:48:14.980] [ERROR] [TSED] - { method: 'GET',
2019-10-28T15:48:14.986702+00:00 app[web.1]: url: '/todos',
2019-10-28T15:48:14.986705+00:00 app[web.1]: headers:
2019-10-28T15:48:14.986707+00:00 app[web.1]: { host: 'apipracticecoding.herokuapp.com',
2019-10-28T15:48:14.986709+00:00 app[web.1]: connection: 'close',
2019-10-28T15:48:14.986711+00:00 app[web.1]: 'cache-control': 'no-cache',
2019-10-28T15:48:14.986714+00:00 app[web.1]: 'postman-token': 'cb8242f3-3b03-4bdc-87b7-f834d428bdc6',
2019-10-28T15:48:14.986719+00:00 app[web.1]: authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZDc2YWUxZTcxMjVkMTM0NjU1MDQ1ZWEiLCJlbWFpbCI6InphY2hhcmllbnppdWtpNDRAZ21haWwuY29tIiwiYWRtaW4iOmZhbHNlLCJpYXQiOjE1NzIxNjk5MjgsImV4cCI6MTU3NDc2MTkyOH0.Pj7-pIbVgU55nvt8MGJY5VqEjXakTfeUjpoZx4QmaoY',
2019-10-28T15:48:14.986721+00:00 app[web.1]: 'user-agent': 'PostmanRuntime/7.2.0',
2019-10-28T15:48:14.986723+00:00 app[web.1]: accept: '*/*',
2019-10-28T15:48:14.986726+00:00 app[web.1]: cookie: 'connect.sid=s%3A5tj0IDsjuZXKsV0Y-g6bqy8O_Hx8QHcj.QvqlLmDoslJQ%2BrcA6IFI89RR02neWilfEuVt0%2FtzSBQ',
2019-10-28T15:48:14.986727+00:00 app[web.1]: 'accept-encoding': 'gzip, deflate',
2019-10-28T15:48:14.98673+00:00 app[web.1]: 'x-request-id': '38515e4f-490e-4bc9-99ef-7d80280aeec5',
2019-10-28T15:48:14.986732+00:00 app[web.1]: 'x-forwarded-for': '41.234.192.84',
2019-10-28T15:48:14.986735+00:00 app[web.1]: 'x-forwarded-proto': 'https',
2019-10-28T15:48:14.986737+00:00 app[web.1]: 'x-forwarded-port': '443',
2019-10-28T15:48:14.986739+00:00 app[web.1]: via: '1.1 vegur',
2019-10-28T15:48:14.986741+00:00 app[web.1]: 'connect-time': '1',
2019-10-28T15:48:14.986743+00:00 app[web.1]: 'x-request-start': '1572277694967',
2019-10-28T15:48:14.986744+00:00 app[web.1]: 'total-route-time': '0' },
2019-10-28T15:48:14.986746+00:00 app[web.1]: body: undefined,
2019-10-28T15:48:14.986748+00:00 app[web.1]: query: {},
2019-10-28T15:48:14.98675+00:00 app[web.1]: params: {},
2019-10-28T15:48:14.986752+00:00 app[web.1]: reqId: '4',
2019-10-28T15:48:14.986754+00:00 app[web.1]: time: 2019-10-28T15:48:14.980Z,
2019-10-28T15:48:14.986756+00:00 app[web.1]: duration: 8,
2019-10-28T15:48:14.986758+00:00 app[web.1]: error:
2019-10-28T15:48:14.986761+00:00 app[web.1]: { message: 'ENOENT: no such file or directory, stat \'/app/dist/client/build/index.js\'',
2019-10-28T15:48:14.986764+00:00 app[web.1]: stack: 'Error: ENOENT: no such file or directory, stat \'/app/dist/client/build/index.js\'',
2019-10-28T15:48:14.986766+00:00 app[web.1]: status: 404,
2019-10-28T15:48:14.986768+00:00 app[web.1]: origin: undefined } }
2019-10-28T15:48:14.986894+00:00 app[web.1]: [2019-10-28T15:48:14.985] [INFO ] [TSED] - { reqId: '4',
2019-10-28T15:48:14.986897+00:00 app[web.1]: method: 'GET',
2019-10-28T15:48:14.986899+00:00 app[web.1]: url: '/todos',
2019-10-28T15:48:14.986901+00:00 app[web.1]: duration: 13,
2019-10-28T15:48:14.986903+00:00 app[web.1]: time: 2019-10-28T15:48:14.985Z,
2019-10-28T15:48:14.986905+00:00 app[web.1]: event: 'request.end',
2019-10-28T15:48:14.986907+00:00 app[web.1]: status: 404 }
2019-10-28T15:48:14.987442+00:00 app[web.1]: GET /todos 404 12.216 ms - 144


当我在本地服务器中查询同一终结点时,一切正常。我不知道在哪里可以找到文件'/app/dist/client/build/index.js \',因为我的构建中没有包含client文件夹

我的server.ts文件

const rootDir = path.resolve(__dirname);
const mongoUrl = MONGODB_URI;
const distDir = __dirname + "/dist/";

@ServerSettings({
  rootDir,
  mongoose : {
    url : mongoUrl,
    connectionOptions: {
      "useNewUrlParser": true,
      "useUnifiedTopology": true
    }
  },
  mount: {
      '/': `${rootDir}/controllers/v1/**/**.controller.{ts,js}`
  },
  componentsScan: [
      `${rootDir}/services/**/**.service.ts`,
      `${rootDir}/middlewares/**/**.ts`
  ],
  httpPort: process.env.PORT || 3001,
  httpsPort: 3443,
  acceptMimes: ['application/json'],
  swagger: {
      path: '/api-docs'
  },
  passport: {}
})
export class Server extends ServerLoader {
  /**
   * This method let you configure the middleware required by your application to works.
   * @returns {Server}
   */
  public async $onMountingMiddlewares(): Promise<any> {
      this
          .use(GlobalAcceptMimesMiddleware)
          .use(bodyParser())
          .use(compression())
          .use(express())
          .use(logger('dev'))
          .use(bodyParser.json())
          .use(bodyParser.urlencoded({
              extended: true
          }))
          .use(expressValidator())
          .use(session({
            resave: true,
            saveUninitialized: true,
            secret: SESSION_SECRET,
            cookie: {
              path: "/",
              httpOnly: true,
              secure: false,
              maxAge: null
            },
            store: new MongoStore({
              url: mongoUrl,
              autoReconnect: true
            })
          }))
          .use(cors())
          .use(flash())
          .use(lusca.xframe("SAMEORIGIN"))
          .use(lusca.xssProtection(true))
          .use(express.static(distDir));


      return null;
  }

  public $onReady() {
      $log.info('Server started...');
      console.log("Server Started ", rootDir);
  }
}

我应该部署此应用程序,以便我的教师可以用来培训自己。任何帮助将不胜感激

0 个答案:

没有答案