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

Import Error in github action #52

Open
proggreg opened this issue Mar 31, 2024 · 6 comments
Open

Import Error in github action #52

proggreg opened this issue Mar 31, 2024 · 6 comments

Comments

@proggreg
Copy link

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
Copy link
Owner

@proggreg can you share a small reproduction? thanks

@Coiggahou2002
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@Coiggahou2002
Copy link
Contributor

Coiggahou2002 commented Apr 12, 2024

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants