vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.96k stars 26.69k forks source link

MODULE_NOT_FOUND in 2 workspaces #60110

Open martinez-hugo opened 8 months ago

martinez-hugo commented 8 months ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/festive-sara-3vry7t

To Reproduce

A monorepo with 3 workspaces :

monorepo managed with turbo

Current vs. Expected behavior

On my local Mac computer, when I try to build or run dev my project, I have this error for src package :

node:internal/modules/cjs/loader:1147
  throw err;
  ^

Error: Cannot find module '/Users/hugomartinez/veille-360/node_modules/src/node_modules/prisma/build/index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

and these error for emails-server package

node:internal/modules/cjs/loader:1147
emails-server:dev:   throw err;
emails-server:dev:   ^
emails-server:dev: 
emails-server:dev: Error: Cannot find module '/Users/hugomartinez/veille-360/emails-server/node_modules/react-email/dist/source/index.js'
emails-server:dev:     at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
emails-server:dev:     at Module._load (node:internal/modules/cjs/loader:985:27)
emails-server:dev:     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
emails-server:dev:     at node:internal/main/run_main_module:28:49 {
emails-server:dev:   code: 'MODULE_NOT_FOUND',
emails-server:dev:   requireStack: []
emails-server:dev: }
emails-server:dev: 
emails-server:dev: Node.js v20.10.0

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
Binaries:
  Node: 20.10.0
  npm: 10.2.5
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.5-canary.34
  eslint-config-next: 14.0.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Operating System (Windows, MacOS, Linux), Package manager (npm, pnpm, Yarn), Turbopack (--turbo)

Additional context

npm config:

; "user" config from /Users/hugomartinez/.npmrc

@lareservetech:registry = "https://npm.pkg.github.com/" 
@LaReserveTech:registry = "https://npm.pkg.github.com/" 
@martinez-hugo:registry = "https://npm.pkg.github.com/" 
//npm.pkg.github.com/:_authToken = (protected) 
engine-strict = true 

; node bin location = /usr/local/bin/node
; node version = v20.10.0
; npm local prefix = /Users/hugomartinez/veille-360
; npm version = 10.2.5
; cwd = /Users/hugomartinez/veille-360
; HOME = /Users/hugomartinez
; Run `npm config ls -l` to show all defaults.

My main package.json

{
    "name": "veille-360",
    "version": "0.1.0",
    "private": true,
    "globalDotEnv": [".env"],
    "scripts": {
        "build": "turbo build",
        "dev": "dotenv -- turbo dev",
        "lint": "turbo lint",
        "format": "prettier --write \"**/*.{ts,tsx,md}\""
    },
    "pipeline": {
        "build": {
            "dotEnv": [
                ".env.production.local",
                ".env.local",
                ".env.production",
                ".env"
            ]
        },
        "dev": {
            "dotEnv": [
                ".env.production.local",
                ".env.local",
                ".env.production",
                ".env"
            ]
        },
        "test": {
            "dotEnv": [
                ".env.production.local",
                ".env.local",
                ".env.production",
                ".env"
            ]
        }
    },
    "workspaces": ["src", "emails-server", "data"],
    "dependencies": {
        "classnames": "^2.5.0",
        "dotenv-cli": "latest"
    },
    "engines": {
        "node": ">=20"
    },
    "devDependencies": {
        "@biomejs/biome": "1.4.1"
    },
    "packageManager": "npm@10.2.5"
}

My src package.json

{
    "name": "src",
    "version": "0.1.0",
    "scripts": {
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "lint": "next lint"
    },
    "dependencies": {
        "@heroicons/react": "^2.1.1",
        "@hookform/resolvers": "^3.3.2",
        "@prisma/client": "^5.7.1",
        "@radix-ui/react-accordion": "^1.1.2",
        "@radix-ui/react-dialog": "^1.0.5",
        "@radix-ui/react-icons": "^1.3.0",
        "@radix-ui/react-label": "^2.0.2",
        "@radix-ui/react-popover": "^1.0.7",
        "@radix-ui/react-scroll-area": "^1.0.5",
        "@radix-ui/react-separator": "^1.0.3",
        "@radix-ui/react-slot": "^1.0.2",
        "@radix-ui/react-toast": "^1.1.5",
        "@react-email/button": "0.0.13",
        "@react-email/components": "^0.0.12",
        "@react-email/html": "0.0.7",
        "@react-email/render": "^0.0.10",
        "@react-email/tailwind": "0.0.13",
        "@vercel/blob": "^0.16.1",
        "@vercel/postgres": "^0.5.1",
        "class-variance-authority": "^0.7.0",
        "clsx": "^2.0.0",
        "date-fns": "^3.0.6",
        "emails-server": "*",
        "geist": "^1.2.0",
        "nanoid": "^5.0.4",
        "next": "^14.0.4",
        "postmark": "^4.0.2",
        "react": "^18.2.0",
        "react-day-picker": "^8.10.0",
        "react-dom": "^18.2.0",
        "react-email": "^1.10.0",
        "react-hook-form": "^7.49.2",
        "tailwind-merge": "^2.2.0",
        "tailwindcss-animate": "^1.0.7",
        "vercel": "^33.0.1",
        "zod": "^3.22.4"
    },
    "devDependencies": {
        "@types/node": "^20",
        "@types/react": "^18.2.46",
        "@types/react-dom": "^18.2.18",
        "@types/uuid": "^9.0.7",
        "autoprefixer": "^10",
        "depcheck": "^1.4.7",
        "eslint": "^8",
        "eslint-config-next": "^14.0.4",
        "postcss": "^8",
        "prettier": "3.1.1",
        "prisma": "^5.7.1",
        "tailwindcss": "^3",
        "typescript": "^5"
    },
    "overrides": {
        "@react-email/render": "^0.0.9"
    }
}

This repo works correctly on vercel and codesandbox but on local computer

PACK-2245

kdy1 commented 8 months ago

What did you do for those packages? Also, did you try the config below?


/** @type {import("next").NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  transpilePackages: [
    "emails-server",
    "data"
  ]
}

module.exports = nextConfig
bangonkali commented 6 months ago

I have the same issue, but somehow only facing it on windows and not on my mac.