nuxt-mongoose icon indicating copy to clipboard operation
nuxt-mongoose copied to clipboard

Import Error in github action

Open proggreg opened this issue 10 months ago • 6 comments

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?

proggreg avatar Mar 31 '24 20:03 proggreg

@proggreg can you share a small reproduction? thanks

arashsheyda avatar Mar 31 '24 21:03 arashsheyda

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 avatar Apr 10 '24 18:04 Coiggahou2002

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:

  • The error messages above were shown during the nuxt build process (after building client bundle and before finish building nitro server bundle)
  • When I run nuxt build on my Mac laptop, the .output/server/chunks/_/model.mjs will include the function implementation of defineMongooseModel, but when running nuxt build on the GitHub Action machine, the .output/server/chunks/_/record.schema.mjs DOES NOT include the implementation of function defineMongooseModel
  • I tried to make a minimal reproduction on StackBlitz but FAILED because the nuxt build runs very well on the StackBlitz's container

Coiggahou2002 avatar Apr 10 '24 18:04 Coiggahou2002

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

Coiggahou2002 avatar Apr 11 '24 11:04 Coiggahou2002

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

Coiggahou2002 avatar Apr 12 '24 09:04 Coiggahou2002

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

arashsheyda avatar Apr 12 '24 14:04 arashsheyda