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

Nuxt >=3.6.5 : Cannot find module and RollupError: Could not resolve #22958

Closed
alimozdemir opened this issue Sep 2, 2023 · 13 comments
Closed

Comments

@alimozdemir
Copy link

Environment

My local



Reproduction

  • Operating System: Linux
  • Node Version: v16.20.0
  • Nuxt Version: 3.6.5
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-f5iwgw?file=app.vue

Describe the bug

In my local, I'm receiving the following error first


 ERROR  RollupError: Could not resolve "./AutoCollection/CorrelationContextManager" from "./AutoCollection/CorrelationContextManager?commonjs-external"   nitro 12:06:28

                                                                                                                                                                12:05:54  
undefined

Then whenever I open the webpage it gives me following error

Cannot find module './AutoCollection/CorrelationContextManager' Require stack: - /home/projects/nuxt-starter-f5iwgw/applicationinsights

image

Additional context

I tested with Nuxt 3.6.5 and Nuxt 3.7.0.

It works in 3.5.3 without any issues.

Logs

No response

@stackblitz
Copy link

stackblitz bot commented Sep 2, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@peteromano
Copy link

Could this be related to 3.7 issue #22918

?

@alimozdemir
Copy link
Author

@peteromano it might be, but this is not working with 3.6.5 I'm pretty sure about it. There is a rollup error in my case as well.

If the both 3.6.5 and 3.7.0 uses the same vite-node version then it might be the same.

@danielroe
Copy link
Member

danielroe commented Sep 3, 2023

Does this replicate if you do not name your project folder applicationinsights?

edit: misread issue

@alimozdemir
Copy link
Author

As I see, it is labeled as a minor bug on vite. Should I link this issue to vite repository? Are they going to fix it or nuxt team is going to fix it? @danielroe

Copy link
Member

In this case it just means that the error is being emitted from our vite-node integration. I'm not in fact sure whether this is a Nuxt issue or elsewhere.

In any case, it can be worked around with:

export default defineNuxtConfig({
  build: {
    transpile: ['applicationinsights']
  }
})

@alimozdemir
Copy link
Author

It seems like it might be workaround in the reproduction. I just tested there and it seems like it is working.

In my local (windows)

I received this error

 ERROR  [worker reload] [worker init] __dirname is not defined in ES module scope                                                                                                                   15:19:25

  at JsonConfig._loadJsonFile (/.nuxt/dev/index.mjs:1856:40)
  at new JsonConfig (/.nuxt/dev/index.mjs:1838:14)
  at JsonConfig.getInstance (/.nuxt/dev/index.mjs:1842:36)
  at /.nuxt/dev/index.mjs:1983:51
  at /.nuxt/dev/index.mjs:2023:3
  at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

@alimozdemir
Copy link
Author

alimozdemir commented Sep 4, 2023

It seems like it might be workaround in the reproduction. I just tested there and it seems like it is working.

In my local (windows)

I received this error

 ERROR  [worker reload] [worker init] __dirname is not defined in ES module scope                                                                                                                   15:19:25

  at JsonConfig._loadJsonFile (/.nuxt/dev/index.mjs:1856:40)
  at new JsonConfig (/.nuxt/dev/index.mjs:1838:14)
  at JsonConfig.getInstance (/.nuxt/dev/index.mjs:1842:36)
  at /.nuxt/dev/index.mjs:1983:51
  at /.nuxt/dev/index.mjs:2023:3
  at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

I was developing applicationinsight as a separated extends. I think this is the issue whenever I put transpile configuration as you suggest. I just moved everything outside of extend then it started to work.

I thought it was related with extends but it is related with server/middleware. Please see the example below

Copy link
Member

Would you provide a more precise reproduction in that case?

@alimozdemir
Copy link
Author

Sure, so I've been investigating it a little bit sorry about the late response.

I've tried to do the same thing in the stackblitz and it seems it is working in the linux environment. In my local env (windows), when I look into the code of .nuxt/dev/index.mjs

it includes applicationinsight library into index.mjs, there are a lot of codes that related with applicationinsight package.

e.g.

image

here is a reproduction link https://stackblitz.com/edit/nuxt-starter-cdamuw?file=nuxt.config.ts

@alimozdemir
Copy link
Author

alimozdemir commented Sep 7, 2023

Currently, I'm facing this issue even whether it is used by "extends" or not. When I'm using this package under server/middleware, it breaks the server side and I get the above error.

I think this is related to nitrojs/nitro#808

@danielroe any news on it?

@alimozdemir
Copy link
Author

@danielroe
Copy link
Member

let's track upstream in nitrojs/nitro#1726.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants