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

Module not found: Relative imports outside of src/ are not supported. #126

Open
jotaachm opened this issue Jul 18, 2024 · 0 comments
Open

Comments

@jotaachm
Copy link

Hi!

Thanks so much for this monorepo - it's exactly what I need for my project! However, I've been unable to get it to work for my apps. When trying to run my web app I am getting this error:

Module not found: Error: You attempted to import expo-monorepo-example/node_modules/@pmmmwh/react-refresh-webpack-plugin/node_modules/react-refresh/runtime.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.

I have a mobile app with this package.json

{
  "name": "acme-mobile",
  "main": "index.js",
  "version": "1.0.0",
  "scripts": {
    "dev": "expo start",
    "reset-project": "node ./scripts/reset-project.js",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --watchAll",
    "lint": "expo lint"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/vector-icons": "^14.0.2",
    "@react-native-async-storage/async-storage": "^1.24.0",
    "@react-navigation/native": "^6.0.2",
    "@tanstack/react-query": "^5.51.1",
    "@acme/shared": "workspace:*",
    "axios": "^1.7.2",
    "expo": "~51.0.20",
    "expo-constants": "~16.0.2",
    "expo-font": "~12.0.8",
    "expo-linking": "~6.3.1",
    "expo-localization": "~15.0.3",
    "expo-router": "~3.5.18",
    "expo-splash-screen": "~0.27.5",
    "expo-status-bar": "~1.12.1",
    "expo-system-ui": "~3.0.7",
    "expo-web-browser": "~13.0.3",
    "i18next": "^23.12.1",
    "nativewind": "^2.0.11",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-i18next": "^14.1.2",
    "react-native": "0.74.3",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-heroicons": "^4.0.0",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.1",
    "react-native-screens": "3.31.1",
    "react-native-svg": "^15.4.0",
    "react-native-web": "~0.19.10"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.2.45",
    "@types/react-test-renderer": "^18.0.7",
    "jest": "^29.2.1",
    "jest-expo": "~51.0.3",
    "react-test-renderer": "18.3.1",
    "tailwindcss": "3.3.2",
    "typescript": "~5.3.3"
  },
  "private": true
}

A React web app with this package.json

{
  "name": "@acme/web",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://127.0.0.1:5000",
  "dependencies": {
    "@emotion/react": "^11.10.6",
    "@emotion/styled": "^11.10.6",
    "@headlessui/react": "^1.7.18",
    "@heroicons/react": "^2.0.16",
    "@mui/material": "^5.12.1",
    "@react-pdf/renderer": "^3.3.8",
    "@tanstack/react-query": "^4.29.7",
    "@tanstack/react-query-devtools": "^4.29.7",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.3.4",
    "bcrypt": "^5.1.0",
    "bcryptjs": "^2.4.3",
    "chart.js": "^4.4.3",
    "chartjs-adapter-moment": "^1.0.1",
    "chartjs-plugin-annotation": "^3.0.1",
    "clsx": "^1.2.1",
    "env-cmd": "^10.1.0",
    "i18next": "^23.4.1",
    "i18next-browser-languagedetector": "^7.1.0",
    "install": "^0.13.0",
    "npm": "^10.1.0",
    "react": "^18.2.0",
    "react-calendly": "^4.1.1",
    "react-chartjs-2": "^5.2.0",
    "react-dom": "^18.2.0",
    "react-i18next": "^13.0.3",
    "react-joyride": "^2.7.2",
    "react-number-format": "^5.1.4",
    "react-pdf": "^7.7.0",
    "react-router-dom": "^6.8.2",
    "react-scripts": "5.0.1",
    "react-spring": "^9.7.1",
    "react-tooltip": "^5.22.0",
    "react-youtube": "^10.1.0",
    "uuid": "^9.0.0",
    "web-vitals": "^2.1.4"
  },
  "engines": {
    "node": ">=12.0.0"
  },
  "scripts": {
    "dev": "react-scripts start",
    "build": "react-scripts build",
    "lint": "eslint \"src/**/*.js\"",
    "lintfix": "eslint --fix \"src/**/*.js\"",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:staging": "env-cmd -f .env.staging npm run build"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@babel/cli": "^7.22.5",
    "@babel/core": "^7.22.5",
    "@babel/eslint-parser": "^7.22.5",
    "@babel/plugin-syntax-jsx": "^7.22.5",
    "@babel/plugin-syntax-typescript": "^7.22.5",
    "@babel/preset-env": "^7.22.5",
    "@babel/preset-react": "^7.22.5",
    "@tailwindcss/forms": "^0.5.3",
    "autoprefixer": "^10.4.13",
    "eslint": "^8.42.0",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-react": "^7.32.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.2.7"
  }
}

A shared package

{
  "name": "@acme/shared",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@babel/preset-react": "^7.24.7",
    "@tanstack/react-query": "^5.51.1",
    "expo-router": "~3.5.18",
    "axios": "^1.7.2",
    "i18next": "^23.11.5",
    "i18next-browser-languagedetector": "^8.0.0",
    "react-i18next": "^14.1.2",
    "react-native": "0.74.3",
    "@react-native-async-storage/async-storage": "^1.24.0"
  },
  "devDependencies": {
    "@babel/preset-react": "^7.24.7"
  }
}

And the rest is unchanged from the template.

Thank you very much to anyone who can provide any guidance! Let me know if you need more info

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

1 participant