whythawk / full-stack-fastapi-postgresql

Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Nuxt3, Docker, automatic HTTPS and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

frontend build error

pabloapast opened this issue · comments

Hi! I'm having issues running the frontend service with the following error during docker-compose up -d:

frontend_1      | yarn run v1.22.19
frontend_1      | $ nuxt start
frontend_1      | /bin/sh: 1: nuxt: not found
frontend_1      | error Command failed with exit code 127.
frontend_1      | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any idea about what's happening here?

Hi @pabloapast, I've got specific notes about it in the readme, and this [closed] issue #9

As far as I can tell, the script which nuxt start should run calls node_modules/nuxt/bin/nuxt.mjs dev ... this is supposed to be in the path, but seems not to be when running docker-compose.override.yml.

Meaning, when you run the development frontend it fails with the errors you raise.

I have tried to find how this happens, but have hit a brick wall. It's something to do with docker-compose, node or nuxt, but I'm really not experienced enough with any of these to track it down.

There have been a lot of Nuxt 3.0 bugfixes, and I'll pull it up to the latest version and see if that helps. Other than that, maybe this helps someone figure it out?

Alternatively, do as suggested in the readme:

NOTE: I find that the Nuxt container does not run well in development mode, and does not refresh on changes. In particular, nuxt/content is very unpredictable in dev mode running in the container. It is far better to run the frontend outside of the container to take advantage of live refresh.

Change into the /frontend folder, and:

yarn install
yarn dev

Just note that you'll use http://localhost:3000 and not http://localhost to reach it, although the api will still be at the backend http://localhost/api/v1.

And, closest I can get to a semi-generalised solution is this: https://stackoverflow.com/questions/68581567/sh-1-nuxt-not-found-heroku-nuxt

Update package.json:

 "scripts": {
    "dev": "node_modules/nuxt/bin/nuxt.mjs nuxt dev -c ./nuxt.config.ts",
    "build": "node_modules/nuxt/bin/nuxt.mjs build -c ./nuxt.config.ts",
    "start": "node_modules/nuxt/bin/nuxt.mjs start -c ./nuxt.config.ts",
    "generate": "nuxt generate",
  },

And variations ... and the "variations" is the trouble. This doesn't appear generalisable.

Release 0.7.1 should fix this.

For reference: https://stackoverflow.com/a/32785014

When docker builds the image, the node_modules directory is created within the worker directory, and all the dependencies are installed there. Then on runtime the worker directory from outside docker is mounted into the docker instance (which does not have the installed node_modules), hiding the node_modules you just installed. You can verify this by removing the mounted volume from your docker-compose.yml.