vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.32k stars 1.82k forks source link

MODULE_NOT_FOUND in 2 workspaces #6865

Closed martinez-hugo closed 10 months ago

martinez-hugo commented 10 months ago

Verify canary release

Link to code that reproduces this issue

https://github.com/martinez-hugo/veille-360

What package manager are you using / does the bug impact?

npm

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

turbo@1.11.3-canary.1

Describe the Bug

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

Expected Behavior

Ability to build or run dev without erros

To Reproduce

A monorepo with 3 workspaces :

monorepo managed with turbo

Additional context

Environment

@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.

martinez-hugo commented 10 months ago

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"
}
martinez-hugo commented 10 months ago

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"
    }
}
chris-olszewski commented 10 months ago

Can you verify that the issue only comes when turbo is used to invoke your scripts? i.e. instead of turbo dev --filter=src run cd src; npm dev

Also, the repository you linked to is private. If this intentional and adding me as a contributor should let me view and help you debug the turbo issue.

martinez-hugo commented 10 months ago

Thanks for your feedback @chris-olszewski

problem is same when I run npm run dev

this is a code replication example of my repo on codesandbox

https://codesandbox.io/p/devbox/festive-sara-3vry7t?file=%2Fbiome.json%3A29%2C1&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clqw840an00073b6k2g2b3fg3%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clqw840an00023b6k6ht628vs%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clqw840an00053b6k4a59gsqy%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clqw840an00063b6kfph39gc7%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clqw840an00023b6k6ht628vs%2522%253A%257B%2522id%2522%253A%2522clqw840an00023b6k6ht628vs%2522%252C%2522tabs%2522%253A%255B%255D%257D%252C%2522clqw840an00063b6kfph39gc7%2522%253A%257B%2522id%2522%253A%2522clqw840an00063b6kfph39gc7%2522%252C%2522tabs%2522%253A%255B%255D%257D%252C%2522clqw840an00053b6k4a59gsqy%2522%253A%257B%2522id%2522%253A%2522clqw840an00053b6k4a59gsqy%2522%252C%2522activeTabId%2522%253A%2522clqw8a3jk00b63b6jg8hth7bd%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clqw840an00033b6klkj0q3ni%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%252C%257B%2522id%2522%253A%2522clqw840an00043b6k0quone5k%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522build%2522%257D%252C%257B%2522id%2522%253A%2522clqw8a3jk00b63b6jg8hth7bd%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clqw8a3ma000fegh5fpjnbx05%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

It works also correctly like on Vercel but my problem appear only in my local computer

chris-olszewski commented 10 months ago

Given that this happens without turbo in the mix this is probably an issue with the setup of the monorepo or your local machine. It could be Node version related or npm version / configuration.

Nothing immediately jumps out to me and I'm afraid I don't have the bandwidth to take a deeper look at your setup. If I misunderstood and this is an issue with turbo then please reopen.

martinez-hugo commented 10 months ago

@chris-olszewski I check one thing that maybe we will help us

If I run any dev or build command on root folder of my repo, it doesn't work But if i run npm run dev on my src package, it works but with one alert :

npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.

What do you think about this ?

chris-olszewski commented 10 months ago

Which package manager are you using? I noticed that you have a yarn.lock and see yarn run v1.22.19 in the logs on the sandbox, but you have npm listed as a package manager and use npm run dev in other places.

Can you try removing the pipeline definition in the primary package.json, it's unnecessary since turbo.json is present.