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

Issue with Nuxt 3 Layers and Nuxt i18n with remote layer #2491

Open
SGDS-SyL opened this issue Oct 13, 2023 Discussed in #2388 · 7 comments
Open

Issue with Nuxt 3 Layers and Nuxt i18n with remote layer #2491

SGDS-SyL opened this issue Oct 13, 2023 Discussed in #2388 · 7 comments
Labels

Comments

@SGDS-SyL
Copy link

Running into the same issue as discussion, Layer works locally but when changed to Github repo. It failed with this:

Failed to resolve import "/lang/en.json" from ".nuxt\i18n.options.mjs"
I've checked and the file do exist.

Discussed in #2388

Originally posted by ionutfrent September 8, 2023

Issue Description

Package Name/Repository: Nuxt 3 with Layers

Nuxt i18n Version: "@nuxtjs/i18n": "v8.0.0-rc.4"

Issue Details

I am currently working with Nuxt 3 Layers for my project. When I extend Layers from local repositories, everything works perfect. However, when I try to extend Layers from a GitHub repository link, I encounter an issue with the Nuxt i18n package. The specific error message I'm getting is:

ERROR No lockfile found from /***/node_modules/base-app

It's important to note that I have the latest version of "@nuxtjs/i18n" (v8.0.0-rc.4) installed in all Layers.

Steps to Reproduce

To reproduce this issue, follow these steps:

  • Create a Nuxt 3 project as a base Layer.

  • Use Nuxt i18n in the base Layer.

  • Push the project to a GitHub repository.

  • Create a Nuxt 3 project which extends the base Layer from the GitHub repository link.

  • Install the dependencies.

The base-app layer is added as a dependency in package.json as follows:
"dependencies": { "base-app": "git+ssh://github_pat_***@github.com:***/base-app.git" }

Expected Behavior

I expected the project to run without errors when extending Layers from a GitHub repository while using the latest version of Nuxt i18n.

Actual Behavior

Instead, I encountered the "No lockfile found" error as described above.

Additional Notes

I'd like to highlight that the described issue appears to be introduced in the latest versions of the library. To provide some context, I experimented with an alpha version of the library, and I couldn't reproduce the issue. This suggests that there might be a regression or compatibility issue in the most recent releases of the library, specifically affecting projects using Nuxt 3 Layers in conjunction with Nuxt i18n.

cc/ @kazupon
I would appreciate any assistance or insights from the community or individuals experienced with Nuxt 3 Layers and Nuxt i18n.

@github-actions
Copy link

Would you be able to provide a reproduction? 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If needs reproduction labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 Reproduction starter (v8 and higher)
👉 Reproduction starter (edge)

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible. See more details in our guide.

You might also find these other articles interesting and/or helpful:

@derHodrig
Copy link

derHodrig commented Oct 18, 2023

Thank you for opening an issue.

Just to inform as written in the discussion:
"@nuxtjs/i18n": "8.0.0-beta.4" solves the installation error (every newer version breaks) but with that version all translations in the layer need to move to the application.

@BobbieGoede
Copy link
Collaborator

I would like to look into this issue but I will need a minimal reproduction to debug the exact issue. 😅

Nuxt 3.8.0 has layer improvements which may tackle the underlying issue here.

@derHodrig
Copy link

derHodrig commented Oct 23, 2023

Reproduction Steps

  1. Checkout https://github.com/derHodrig/nuxt-i18n-reproduction
  2. navigate to i18n-app
  3. run npm install

Install should fail

  • i18n-app is the app and has the dependency "@skoenfeld/i18n-layer": "0.0.2"
  • i18n-layer is the package @skoenfeld/i18n-layer and has the "@nuxtjs/i18n": "^8.0.0-rc.5" dependency
  • @skoenfeld/i18n-layer is the published package

Note: Both, Layer and App do not have any configuration in their nuxt.config.ts, because the issue is in the installation of the layer. You should observe this error:

npm ERR!  ERROR  No lockfile found from ...\i18n-reproduction\i18n-app\node_modules\@skoenfeld\i18n-layer
npm ERR!
npm ERR!   at resolveLockfile (.../i18n-reproduction/i18n-app/node_modules/pkg-types/dist/index.mjs:122:9)
npm ERR!   at async getPackageManagerType (.../i18n-reproduction/i18n-app/node_modules/@nuxtjs/i18n/dist/module.mjs:108:26)

its my first reproduction, feel free to improve me via critics ^^

@BobbieGoede
Copy link
Collaborator

BobbieGoede commented Nov 17, 2023

@derHodrig
I believe the issue you're experiencing is because the layer runs nuxt prepare because of the npm postinstall script, but lockfiles are not published in npm packages. Can you try removing the postinstall script and check if it works again? And of course I recommend installing the edge release channel as it includes most recent bug fixes!

its my first reproduction, feel free to improve me via critics ^^

It's a good reproduction! As it is an npm package it is a bit hard to make changes and test, but that's something inherent to this specific issue 😅

@derHodrig
Copy link

derHodrig commented Nov 21, 2023

@BobbieGoede did not think that this problem is that simple solved.

@SGDS-SyL could you please rename your postinstall script in your layer>package.json and install the new published layer?
derHodrig/nuxt-i18n-reproduction@4c88663#diff-b68b7af82dbabeceff18a29ef8697de0c088349cd1b2a4f0a872ec92095c7802

In my case, in the reproduction, the issue was solved.

Downturn is, after your install deps in the layer, you have to manually use the nuxt prepare .playground

@BobbieGoede
Copy link
Collaborator

In my case, in the reproduction, the issue was solved.

Glad to hear the issue was solved for you!

Downturn is, after your install deps in the layer, you have to manually use the nuxt prepare .playground

Hmm, have you tried updating the module to the latest edge release and seeing if the error is still thrown when keeping the postinstall script?

npm ERR!   at async getPackageManagerType (.../i18n-reproduction/i18n-app/node_modules/@nuxtjs/i18n/dist/module.mjs:108:26)

I believe the code that is throwing this error has been removed and is not present in the edge release.

@BobbieGoede BobbieGoede removed the v8 label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants