question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module in the workspace?

See original GitHub issue

What version of Turborepo are you using?

1.3.1

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

Yarn v1

What operating system are you using?

Mac

Describe the Bug

First of all, thank you for this amazing project. We’ve been enjoying using turborepo for the past 6 months and we love it so far!

I’m not sure if this is a bug report, but after digging into the issues and discussions, I couldn’t find anything near the problem we are currently facing and after triple checking the docs and a few hours of debug, we decided to open an issue ✋

We’re currently using Vercel and deploying an api using Fastify, we are using a similar setup than this one, we named it @acme/api for the reproduction.

When trying to import another package (@acme/utils) into the @acme/api project, the project would not build:

NowBuildError: src/app.ts(2,23): error TS2307: Cannot find module '@acme/utils' or its corresponding type declarations.

I made the logs public, if it helps: https://turbo-vercel-repro-h8fvyigkv-blatty.vercel.app/_logs

And here’s our turbo.json:

{
  "$schema": "https://turborepo.org/schema.json",
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", "build/**", ".next/**", "public/**"]
    },
    "@acme/api#build": {
      "dependsOn": ["^build", "@acme/utils#build"],
      "outputs": ["dist/**", "build/**"]
    },
    "@acme/utils#build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**"]
    },
    "start": {
      "cache": false
    },
    "dev": {
      "cache": false
    }
  },
  "baseBranch": "origin/main",
  "globalDependencies": ["$GITHUB_TOKEN", "tsconfig.json"]
}

Expected Behavior

Expected @acme/utils to be included in @acme/api

To Reproduce

  1. Clone the reproduction repo: https://github.com/Blatty/turbo-vercel-repro
  2. Deploy to vercel, set the root directory to apps/api
  3. Set the build command to cd ../../ && npx turbo run build --filter=@acme/api

We also tried with --no-cache & --force, yarn install --cwd ../.. as the “install command” to trigger the postinstall but without success 😞

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nathanhammondcommented, Jul 5, 2022

@styfle I believe that this is the minimal reproduction: https://github.com/nathanhammond/workspace-symlink-issue

It fails differently, but I’m ~sure that it’s the same root cause. (Early vs. late failure.)

Vercel configuration:

  • build: cd ../.. && yarn build
  • install cd ../.. && yarn
  • root directory: apps/api
1reaction
styflecommented, Jul 14, 2022

This change was only applied to vercel build. Try with ENABLE_VC_BUILD=1 environment variable and deploy again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
This error can be encountered if you are require ing a module that has a missing or incorrect main ...
Read more >
Receiving an error in workspace console. Cannot find module.
I know it has been a while since you asked this, but if you still need an answer I believe it is because...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
When you get the “cannot find module” error, or “module not found”, it means you've not installed the package you're trying to use....
Read more >
Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
Read more >
Error: Cannot find module in JavaScript [SOLVED]
Why we get “Error: Cannot find module”? · Solution: Install missing module using Node Package Manager. Method-1: npm install; Method-2: npm install -g;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found