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.

Monorepo "Could not resolve" errors @0.7.3

See original GitHub issue

Hello y’all! I wanted to start using this package unfortunately as soon as I ran npx mailing I received a lot of could not resolve errors

Quick Information

  • Operating System: Windows 10
  • β€œmailing”: β€œ^0.7.3”,
  • β€œmailing-core”: β€œ^0.7.3”,
  • β€œnext”: β€œ^12.2.0”,
  • β€œreact”: β€œ17.0.2”,
  • β€œreact-dom”: β€œ17.0.2”,

What Happened?

  • installed mailing and mailing-core in one of my turborepo apps
  • ran npx mailing
  • got the following error in my terminal
    β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—
    β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β•β•β•
    β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ–ˆβ•—
    β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘
    β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•
    β•šβ•β•     β•šβ•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•šβ•β•β•β•β•β•β•β•šβ•β•β•šβ•β•  β•šβ•β•β•β• β•šβ•β•β•β•β•β•


mailing added mailing.config.json to your project with the following contents:
{
  "typescript": true,
  "emailsDir": "./emails",
  "outDir": "./previews_html"
}

mailing generated your emails dir at ./emails:
emails
β”œβ”€β”€ TextEmail.tsx
β”œβ”€β”€ Welcome.tsx
β”œβ”€β”€ components
β”‚   β”œβ”€β”€ BulletedList.tsx
β”‚   β”œβ”€β”€ ButtonPrimary.tsx
β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”œβ”€β”€ Head.tsx
β”‚   β”œβ”€β”€ Header.tsx
β”‚   └── theme.ts
β”œβ”€β”€ index.ts
└── previews
    β”œβ”€β”€ TextEmail.tsx
    └── Welcome.tsx
√ enter your email for occasional updates about mailing (optional) ...
mailing ok, no problem
mailing starting preview server
mailing adding .gitignore
✘ [ERROR] Could not resolve "....emails"

    .mailing/src/moduleManifest.ts:2:21:
      2 β”‚ import sendMail from "..\..\emails";
        β•΅                      ~~~~~~~~~~~~~~

  You can mark the path "....emails" as external to exclude it from the bundle, which will remove
  this error.

✘ [ERROR] Could not resolve "....emails/TextEmail"

    .mailing/src/moduleManifest.ts:3:22:
      3 β”‚ import TextEmail from "..\..\emails/TextEmail";
        β•΅                       ~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "....emails/TextEmail" as external to exclude it from the bundle, which will
  remove this error.

✘ [ERROR] Could not resolve "....emails/Welcome"

    .mailing/src/moduleManifest.ts:4:20:
      4 β”‚ import Welcome from "..\..\emails/Welcome";
        β•΅                     ~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "....emails/Welcome" as external to exclude it from the bundle, which will
  remove this error.

✘ [ERROR] Could not resolve "....emails/previews/TextEmail"

    .mailing/src/moduleManifest.ts:5:34:
      5 β”‚ import * as TextEmailPreview from "..\..\emails/previews/TextEmail";
        β•΅                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "....emails/previews/TextEmail" as external to exclude it from the bundle,
  which will remove this error.

✘ [ERROR] Could not resolve "....emails/previews/Welcome"

    .mailing/src/moduleManifest.ts:6:32:
      6 β”‚ import * as WelcomePreview from "..\..\emails/previews/Welcome";
        β•΅                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "....emails/previews/Welcome" as external to exclude it from the bundle,
  which will remove this error.

G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:1624
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 5 errors:
.mailing/src/moduleManifest.ts:2:21: ERROR: Could not resolve "....emails"
.mailing/src/moduleManifest.ts:3:22: ERROR: Could not resolve "....emails/TextEmail"
.mailing/src/moduleManifest.ts:4:20: ERROR: Could not resolve "....emails/Welcome"
.mailing/src/moduleManifest.ts:5:34: ERROR: Could not resolve "....emails/previews/TextEmail"
.mailing/src/moduleManifest.ts:6:32: ERROR: Could not resolve "....emails/previews/Welcome"
    at failureErrorWithLog (G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:1624:15)
    at G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:1266:28
    at runOnEndCallbacks (G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:1179:65)
    at buildResponseToResult (G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:1264:7)
    at G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:1377:14
    at G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:678:9
    at handleIncomingPacket (G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:775:9)
    at Socket.readFromStdout (G:\dev\d-mls-app\node_modules\esbuild\lib\main.js:644:7)
    at Socket.emit (node:events:526:28)
    at addChunk (node:internal/streams/readable:315:12) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 21,
        file: '.mailing/src/moduleManifest.ts',
        length: 14,
        line: 2,
        lineText: 'import sendMail from "..\\..\\emails";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "....emails" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "....emails"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 22,
        file: '.mailing/src/moduleManifest.ts',
        length: 24,
        line: 3,
        lineText: 'import TextEmail from "..\\..\\emails/TextEmail";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "....emails/TextEmail" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "....emails/TextEmail"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 20,
        file: '.mailing/src/moduleManifest.ts',
        length: 22,
        line: 4,
        lineText: 'import Welcome from "..\\..\\emails/Welcome";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "....emails/Welcome" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "....emails/Welcome"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 34,
        file: '.mailing/src/moduleManifest.ts',
        length: 33,
        line: 5,
        lineText: 'import * as TextEmailPreview from "..\\..\\emails/previews/TextEmail";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "....emails/previews/TextEmail" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "....emails/previews/TextEmail"'
    },
    {
      detail: undefined,
      id: '',
      location: {
        column: 32,
        file: '.mailing/src/moduleManifest.ts',
        length: 31,
        line: 6,
        lineText: 'import * as WelcomePreview from "..\\..\\emails/previews/Welcome";',
        namespace: '',
        suggestion: ''
      },
      notes: [
        {
          location: null,
          text: 'You can mark the path "....emails/previews/Welcome" as external to exclude it from the bundle, which will remove this error.'
        }
      ],
      pluginName: '',
      text: 'Could not resolve "....emails/previews/Welcome"'
    }
  ],
  warnings: []
}
  • I went to check the moduleManifest.ts file in the .mailing/src/moduleManifest.ts and saw the following
import config from "../../mailing.config.json";
import sendMail from "..\..\emails";
import TextEmail from "..\..\emails/TextEmail";
import Welcome from "..\..\emails/Welcome";
import * as TextEmailPreview from "..\..\emails/previews/TextEmail";
import * as WelcomePreview from "..\..\emails/previews/Welcome";

const previews = { TextEmail: TextEmailPreview, Welcome: WelcomePreview };
const templates = { TextEmail, Welcome };

export { sendMail, config, templates, previews };
const moduleManifest = { sendMail, templates, previews };
export default moduleManifest;

With red typescript errors on the paths with the following typescript error

Cannot find module '....emails' or its corresponding type declarations.ts(2307)

Expected result

  • run npx mailing and the import paths are correct and runs with no error

Steps to reproduce

# Install a turborepo from scratch
npx create-turbo@latest

# Chose a dir
Where would you like to create your turborepo? ./mailing-test
# choose npm
? Which package manager do you want to use? npm

# CD into the web app
cd mailing-test/apps/web

# add new dependencies
npm i mailing mailing-core

#run mailing cli
npx mailing

# errors appear :(
✘ [ERROR] Could not resolve "....emails"

   .mailing/src/moduleManifest.ts:2:21:
     2 β”‚ import sendMail from "..\..\emails";

Screenshots

image

Please let me know if you need anything else!

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
alexisveryrealcommented, Sep 9, 2022

@alexfarrill No more npm -g root error, but paths errors are still there. This time though they are all the same type of slash at least.

So 0.7.3 import TextEmail from "..\..\emails/TextEmail"; image

0.7.7-next-0 import TextEmail from "..\..\emails\TextEmail"; image

1reaction
alexfarrillcommented, Sep 9, 2022

if you want to add some detail on how to setup turborepo to #178 that one should be easy to implement

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vercel is not working in a monorepo Β· Issue #4567 - GitHub
When I deploy using the vercel CLI the function no longer produces the error message and the application starts working. I'm using the...
Read more >
Hosting all your PHP packages together in a monorepo
Learn to manage a monorepo, a tool that helps to handle the complexity of large codebases by hosting all PHP packages in a...
Read more >
rbt setup-repo returns with error - git - Stack Overflow
I am using git as my code repository. While trying to setup the review board server form git cmd line rbt returns with...
Read more >
Changelog - Cypress Documentation
Fixed an 11.0.0 regression where using custom reporters would cause Cypress to throw a 'Cannot find module' error. Fixes #24607; Fixed testIsolationΒ ...
Read more >
Things I wish I had known when I started JavaScript monorepo ...
The reason is simple: all packages of the monorepo will be recursively installed by running npm install from monorepo root. The recursiveΒ ...
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