grutt / udacity-c2-restapi

6 stars 131 forks source link

UnhandledPromiseRejectionWarning: TypeError: sequelize_1.Model[(staticMethodPrefix + "conformOptions")] is not a function #7

Open cdCarlos opened 5 years ago

cdCarlos commented 5 years ago

After cloning the repo, installing dependencies, and updating db connection info I'm getting this error when I try to post a new feed. If I get the list of feeds (which are 0) everything works well.

Here is the stack:

(node:9850) UnhandledPromiseRejectionWarning: TypeError: sequelize_1.Model[(staticMethodPrefix + "conformOptions")] is not a function
    at Function.BaseModel.prepareInstantiationOptions (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/sequelize-typescript/lib/models/BaseModel.js:97:69)
    at new Model (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/sequelize-typescript/lib/models/v4/Model.js:8:45)
    at new FeedItem (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/src/controllers/v0/feed/models/FeedItem.ts:17:9)
    at Object.<anonymous> (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/src/controllers/v0/feed/routes/feed.router.ts:76:5)
    at Generator.next (<anonymous>)
    at /home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/src/controllers/v0/feed/routes/feed.router.ts:7:71
    at new Promise (<anonymous>)
    at __awaiter (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/src/controllers/v0/feed/routes/feed.router.ts:3:12)
    at router.post (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/src/controllers/v0/feed/routes/feed.router.ts:55:15)
    at Layer.handle [as handle_request] (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/layer.js:95:5)
    at /home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:335:12)
    at next (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:174:3)
    at router (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:317:13)
    at /home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/cc/Projects/Udacity/cloud-developer-nd/udacity-c2-restapi/node_modules/express/lib/router/index.js:335:12)
(node:9850) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:9850) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any help/hint on how to solve it?

sarah-maris commented 5 years ago

I think there is in a conflict with the sequelize and sequelize-typescript versions in the app. See this issue: https://github.com/RobinBuschmann/sequelize-typescript/issues/583#issuecomment-477785749

I was able to get it to run by downgrading to sequelize 5.1.1 ("sequelize": "5.1.1") or upgrading to to the alpha version of sequelize-typescript: ("sequelize-typescript": "1.0.0-alpha.9"). Either change works. You don't need to do both.

cdCarlos commented 5 years ago

@sarah-maris thanks, it worked!