Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'react' #23

Open
Erik-Wong opened this issue Apr 12, 2024 · 16 comments
Open

Cannot find module 'react' #23

Erik-Wong opened this issue Apr 12, 2024 · 16 comments

Comments

@Erik-Wong
Copy link

Uploading WechatIMG530.jpg…

@Haukez
Copy link

Haukez commented Apr 16, 2024

repl:
load thedocker image with docker pull naskio/strapi
then copied docker-compose-yml
version: "3"
services:
strapi:
image: naskio/strapi
environment:
NODE_ENV: development # or production
ports:
- "1337:1337"

starting the file with docker compose up -d results in a closed container

Screenshot 2024-04-16 021222

@paulkitt
Copy link

Facing the same problem

@itangqiao
Copy link

same problem

image

@itangqiao
Copy link

same problem

image
image

@V-Shadbolt
Copy link

V-Shadbolt commented May 14, 2024

Adding React does not fix the problem in and of itself: react-dom, react-router-dom, and styled-components also will need to be added to the image.

This can be fixed quickly by including the packages in the dockerfile(s) - versions per the error logs

RUN yarn global add @strapi/strapi@${STRAPI_VERSION} && yarn global add "react@^18.0.0" && yarn global add "react-dom@^18.0.0" && yarn global add "react-router-dom@^5.3.4" && yarn global add "styled-components@^5.3.3"

Alternatively, the entire above line in the dockerfile(s) can be dropped as the @strapi/strapi package is what is throwing the dependency errors. Existing projects should start just fine once the line is removed but they will throw a low-level warning for the missing react packages.

For building new Strapi v4 projects with the above removed, migrate the entrypoint(s) from strapi new to yarn create strapi-app@${STRAPI_VERSION} - it is now the recommended way to start a Strapi project per the docs. New projects will be built with the required packages and will use the specified Strapi version.

I just did the migration on my fork for reference. I also included a catch for adding the missing packages to existing projects as well as a version upgrade check to compare the current Strapi project version and the image version; upgrading if necessary.

@naskio I'm happy to open a PR for the migration

@kuncevic
Copy link

kuncevic commented Sep 23, 2024

@V-Shadbolt the fork seems hangs on create app, trying to use >Login/Sign up option

strapi-1  | - ✦ Blazing-fast ✦ deployment for your projects
strapi-1  | - ✦ Exclusive ✦ access to resources to make your project successful
strapi-1  | - An ✦ Awesome ✦ community and full enjoyment of Strapi's ecosystem
strapi-1  | 
strapi-1  | Start your 14-day free trial now!
strapi-1  | 
strapi-1  | 
strapi-1  | ? Please log in or sign up. (Use arrow keys)
strapi-1  | ❯ Login/Sign up 
strapi-1  |   Skip 
strapi-1  | npm notice

I am using default docker compose yaml, starting from the scratch

version: "3"
services:
  strapi:
    image: vshadbolt/strapi:latest
    platform: linux/amd64
    environment:
      NODE_ENV: development # or production
    ports:
      - "1337:1337"
    # volumes:
    #   - ./app:/srv/app # mount an existing strapi project

@V-Shadbolt
Copy link

V-Shadbolt commented Sep 23, 2024

@kuncevic there was a breaking change (in relation to the docker image) between v4 and v5 of Strapi with how the CLI works on project setup. Specifically it prompts user input now for Strapi Cloud login/signup.

Release 4.35.11 of the fork should still work as expected.

There seems to be a flag I can use to bypass the Strapi Cloud questions which should solve the issue but I’ll need to do some testing around it first before I implement it into the docker image.

I would recommend opening this as an issue against my fork for tracking purposes.

@jy1989
Copy link

jy1989 commented Sep 27, 2024

same problem

@V-Shadbolt
Copy link

@jy1989 same problem with my fork or with this one? @kuncevic the issue has been fixed for v4.25.x and v5.x.x. I've also implemented build testing to try avoiding these slipping through moving forward.

@AlanStefanov
Copy link

AlanStefanov commented Oct 22, 2024

I give you two options to move forward:

1: docker run -d -p 1337:1337 naskio/strapi:4.14.5-alpine

2:
docker-compose.yml

services:
strapi:
image: naskio/strapi:4.14.5-alpine
restart: always
environment:

  DATABASE_CLIENT: postgres
  DATABASE_NAME: strapi
  DATABASE_HOST: x
  DATABASE_PORT: 5432
  DATABASE_USERNAME: postsgres
  DATABASE_PASSWORD: x
  APP_KEYS: x
  JWT_SECRET: x
  ADMIN_JWT_SECRET: x
  SMTP_USER: x
  SMTP_PASS: x

// NODE_ENV: production
volumes:
- strapi-data:/srv/app
ports:
- '1337:1337'

volumes:
strapi-data:

@nikola66
Copy link

This is still pretty much a problem in all V4 and v5 versions. Just tried it on CapRover and it keeps looping forever with no sucess
Uploading Screenshot 2024-10-25 145440.png…

@JorisHageman
Copy link

JorisHageman commented Dec 23, 2024

I have the same problem on different versions. Also the latest.

@ruipoliveira
Copy link

same issue v5.9.0

@zebulun78
Copy link

@jy1989 same problem with my fork or with this one? @kuncevic the issue has been fixed for v4.25.x and v5.x.x. I've also implemented build testing to try avoiding these slipping through moving forward.

Shadbolt, thanks for the fork. The image shouldn't be broken out of the box like this. Your image works. Cheers mate!

@zebulun78
Copy link

@V-Shadbolt I spoke too soon. I need mysql which isn't in your entrypoint. I may modify that for my purposes, but for now your solution is on the right track...

@V-Shadbolt
Copy link

V-Shadbolt commented Feb 13, 2025

@zebulun78 shouldn't be hard to replicate the pg logic for mysql. Can you open an issue on my fork?

This should now fixed in my fork in v5.10.2 and 4.25.20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests