AugustoMarcelo / mcuapi

🦸 Marvel Cinematic Universe API
https://mcuapi.herokuapp.com/docs
67 stars 3 forks source link

Problem: Can't run code on a local server #23

Closed ottocol closed 1 year ago

ottocol commented 1 year ago

Modified configuration for using SQLite instead of Postgres. I was able to run migrations, seed database and run in dev mode, but not in production mode. After building with "npm run build" that seems fine, when running "npm run start" I get an error

(path to this file in the src folder)/Movie.ts:1 import { Entity, PrimaryColumn, Column, ManyToMany, JoinTable } from 'typeorm'; ^^^^^^

SyntaxError: Cannot use import statement outside a module

Cloned your repo again, installed postgres locally and tried to build and run your unmodified code but got same error.

Googled for a possible solution but adding/changing several properties in tsconfig.json and package.json didn't worked, and as I am not myself a Typescript developer did not really know what I was doing :) any idea what is the problem? (by the way, very nice project!!)

AugustoMarcelo commented 1 year ago

Hi, @ottocol. Thanks for the feedback and sorry for the delay. Before running the build command, you need to tell your ormconfig.js file that you are in the production environment. In my .env file, I set the NODE_ENV=production. So I run the build and then the start.

I think it's my fault, I forgot to create a document to specify these steps. I'll fix this. Let me know if I can help you with anything.

ottocol commented 1 year ago

Agh. You forgot to create the document and I forgot to set the variable :). Thanks!

AugustoMarcelo commented 1 year ago

You're welcome! I'm closing this issue. Feel free to reopen if you have problems.