async-labs / builderbook

Open source web application to learn JS stack: React, Material-UI, Next.js, Node.js, Express.js, Mongoose, MongoDB database.
https://builderbook.org
MIT License
3.77k stars 893 forks source link

Deploy app to Heroku #520

Closed reingoldkz closed 1 year ago

reingoldkz commented 1 year ago

Hi async-labs team.

I am having error when deploying my app to Heroku cloud.

error: error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error 2023-05-02T04:49:47.866022+00:00 app[web.1]: node:internal/modules/cjs/loader:933 2023-05-02T04:49:47.866022+00:00 app[web.1]: const err = new Error(message); 2023-05-02T04:49:47.866024+00:00 app[web.1]: ^ 2023-05-02T04:49:47.866024+00:00 app[web.1]: 2023-05-02T04:49:47.866025+00:00 app[web.1]: Error: Cannot find module 'next-transpile-modules' 2023-05-02T04:49:47.866026+00:00 app[web.1]: Require stack: 2023-05-02T04:49:47.866029+00:00 app[web.1]: - /app/next.config.js 2023-05-02T04:49:47.866033+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) 2023-05-02T04:49:47.866033+00:00 app[web.1]: at Function.mod._resolveFilename (/app/node_modules/next/dist/build/webpack/require-hook.js:23:32) 2023-05-02T04:49:47.866035+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:778:27) 2023-05-02T04:49:47.866036+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19) 2023-05-02T04:49:47.866036+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18) 2023-05-02T04:49:47.866036+00:00 app[web.1]: at Object. (/app/next.config.js:1:16) 2023-05-02T04:49:47.866037+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14) 2023-05-02T04:49:47.866037+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) 2023-05-02T04:49:47.866037+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32) 2023-05-02T04:49:47.866037+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) { 2023-05-02T04:49:47.866039+00:00 app[web.1]: code: 'MODULE_NOT_FOUND', 2023-05-02T04:49:47.866039+00:00 app[web.1]: requireStack: [ '/app/next.config.js' ] 2023-05-02T04:49:47.866039+00:00 app[web.1]: } 2023-05-02T04:49:48.082546+00:00 heroku[web.1]: Process exited with status 1 2023-05-02T04:49:48.139934+00:00 heroku[web.1]: State changed from starting to crashed


builderbook 9-end project running fine on localhost Also, there is not problem running project on Heroku could when it is 8-end code.

The problem arises after changes on 9th chapter.

Is it because of next.js update, or something else, I can't figure it out.

Could you please take a look at error code and give me some advice.

Thanks

reingoldkz commented 1 year ago

https://www.npmjs.com/package/next-transpile-modules

https://nextjs.org/blog/next-13-1 https://nextjs.org/blog/next-13-1#built-in-module-transpilation-stable

reingoldkz commented 1 year ago

Hi.

I did this project in the past. And also I'm not so good at programming at the moment.

There is some breaking changes in chapter 9.

in my project 9-begin everything is kinda fine, but 9-end, I'm having issue with book chapters. Chapters are not showing when I click to book.

klyburke commented 1 year ago

Hi @reingoldkz Thanks for reporting. We will look into the potential Heroku issue.

Regarding 9-end, are you running our exact code from the repo? I just ran 9-end on my machine and didn't see any issues. I am able to open my sample book and see the chapters.

Try running 9-end directly from our repo with your environmental variables.

Please also share any screenshots or error messages you see regarding "chapters are not showing".

reingoldkz commented 1 year ago

Hi, @klyburke

If you run code locally it works fine.

But when we deploy the code to Heroku, it is giving error: Cannot find module 'next-transpile-modules'

https://nextjs.org/docs/pages/api-reference/next-config-js/transpilePackages

Next.js 13 can automatically transpile and bundle dependencies from local packages (like monorepos) or from external dependencies (node_modules). This replaces the next-transpile-modules package.

Therefor, I think we need to change next.config.js file. But I am beginner, and can't understand, how do it correctly.

My projects running OK on Herorku, but there is the problem with showing chapters of book.

Thanks for your help.

tima101 commented 1 year ago

@reingoldkz Not sure about Heroku deployment. What happens when you have "next-transpile-modules" inside package.json: https://github.com/async-labs/builderbook/blob/master/builderbook/package.json

Please make sure that you run "yarn install" after adding package manually to package.json file.


If problem persists I can try deploying your project to our Heroku account. For that to happen, you can add me to your private repo and provide all necessary instructions inside repo's README.md file.

reingoldkz commented 1 year ago

My problem: Book chapters are not showing up.

And the problem occurs right after this part of the book till the end.

https://builderbook.org/books/builder-book/prepare-project-for-deployment-environmental-variables-production-development-logger-seo-robots-txt-sitemap-xml-compression-and-security-deploy-project-heroku-testing-deployed-project-aws-elastic-beanstalk#next-js-v13-other-package-upgrades

I couldn't figure it out what is the couse.

Maybe I think it is linked to next.config.js file update and code there.

reingoldkz commented 1 year ago

the project running OK on Heroku and loclhost:8000,

but there is a problem with showing book Chapters.

book chapters not showing up on local dev and on Heroku app.

I can't figure it out why.

reingoldkz commented 1 year ago

error: Content sync has error {"error":{},"path":"chapter-1.md"}

reingoldkz commented 1 year ago

Hi async-labs,

My problem is written in above messages,

I want just to give more information.

So, at the 9-begin my code and localhost dev environment runs OK. Everything is fine.

I can add books and chapters show up. Everything is fine.

I continue to make changes on 9-th chapter, till the Next.js v13 and other packages upgrade, and I get error: chapter is not showing up

error: Content sync has error {"error":{},"path":"chapter-1.md"}

reingoldkz commented 1 year ago

my code is from builderbook\9-begin, I have needed env variables,

and then I switch to 9-end code, to check. but problem remains.

I can't sync Chapters. error: Content sync has error {"error":{},"path":"chapter-1.md"}

I looked very closely and invested a lot of time, but can't figure it out. I'm beginner, and should admit that I can't understand all the code, but I am so close to make this project to work

This problem is I can't solve at the moment.

Any assist from your side will be helpful.

Thanks

reingoldkz commented 1 year ago

Breaking change from 9-begin to 9-end in my case was to downgrade marked package version. from "marked": "^4.2.5",

to "marked": "^1.2.7",

tima101 commented 1 year ago

marked should be 1.2.7 inside 9-end project