arashsheyda / nuxt-mongoose

A Nuxt module for simplifying the use of Mongoose in your project.
https://docs.arashsheyda.me/nuxt-mongoose
69 stars 11 forks source link

Import Error in github action #52

Open proggreg opened 2 months ago

proggreg commented 2 months ago

Not sure if this is an issue with the module but I'm having an issue when running nuxt in dev. I get this error [worker reload] [worker init] Package import specifier "#nuxt/mongoose".

Don't suppose you know what the issue might be?

arashsheyda commented 2 months ago

@proggreg can you share a small reproduction? thanks

Coiggahou2002 commented 2 months ago

I met the same issue. The most weird thing is that when I try to build on my mac laptop(in the project folder), it works well, but when I try to build the project on the machine of github actions, it reports error.

(node-resolve plugin) Could not resolve import "#nuxt/mongoose" 
in /home/runner/work/sensor-attention/sensor-attention/server/models/record.schema.ts
 using imports defined in /home/runner/work/sensor-attention/sensor-attention/package.json.

(node-resolve plugin) Could not resolve import "#nuxt/mongoose"
 in /home/runner/work/sensor-attention/sensor-attention/server/models/record.schema.ts 
using imports defined in /home/runner/work/sensor-attention/sensor-attention/package.json.

"#nuxt/mongoose" is imported by "server/models/record.schema.ts", but could not be 
resolved – treating it as an external dependency.
Coiggahou2002 commented 2 months ago

I met the same issue. The most weird thing is that when I try to build on my mac laptop(in the project folder), it works well, but when I try to build the project on the machine of github actions, it reports error.

(node-resolve plugin) Could not resolve import "#nuxt/mongoose" 
in /home/runner/work/sensor-attention/sensor-attention/server/models/record.schema.ts
 using imports defined in /home/runner/work/sensor-attention/sensor-attention/package.json.

(node-resolve plugin) Could not resolve import "#nuxt/mongoose"
 in /home/runner/work/sensor-attention/sensor-attention/server/models/record.schema.ts 
using imports defined in /home/runner/work/sensor-attention/sensor-attention/package.json.

"#nuxt/mongoose" is imported by "server/models/record.schema.ts", but could not be 
resolved – treating it as an external dependency.

Additional information:

Coiggahou2002 commented 2 months ago

I've found the reason and made a minimal reproduction , see #54 😄

Coiggahou2002 commented 2 months ago

Not sure if this is an issue with the module but I'm having an issue when running nuxt in dev. I get this error [worker reload] [worker init] Package import specifier "#nuxt/mongoose".

Don't suppose you know what the issue might be?

I was wondering to ask you if this issue has been resolved? If it is not resolved, please check whether you've specified the uri parameter in the mongoose configuration of nuxt.config.ts?

// nuxt.config.ts
export default defineNuxtConfig({
  // ...
  mongoose: {
    uri: 'your mongodb connection string here',
    options: {},
    modelsDir: 'models',
  },
})

I've made a reproduction 👉 nuxt-mongoose PR issue#52 reproduction [worker init] (forked) - StackBlitz. In this reproduction, run npm i and npm run dev to reproduce the [worker init] [woker reload] .... error above, then add uri to mongoose.uri in nuxt.config.ts, the error will not ring anymore.

It's nearly the same problem as #54.

cc @arashsheyda

arashsheyda commented 2 months ago

I'll make a release later today and then we can make sure. thanks again