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

Dependency not found klona/full #1004

Closed
1 of 2 tasks
provok-me opened this issue Dec 21, 2020 · 22 comments · Fixed by #1008
Closed
1 of 2 tasks

Dependency not found klona/full #1004

provok-me opened this issue Dec 21, 2020 · 22 comments · Fixed by #1008
Labels

Comments

@provok-me
Copy link

provok-me commented Dec 21, 2020

Version

nuxt-i18n: 6.16.0
nuxt: 2.14.12

Nuxt configuration

mode:

  • universal
  • spa

Steps to reproduce

Upgrade or install nuxt-i18n.

What is Expected?

The lib is expected to work.

What is actually happening?

It doesn't... (See the issue's title)

This dependency was not found:                                                                
* klona/full in ./.nuxt/nuxt-i18n/plugin.main.js
To install it, you can run: npm install --save klona/full
@rchl
Copy link
Collaborator

rchl commented Dec 21, 2020

#994

@provok-me
Copy link
Author

provok-me commented Dec 21, 2020

#994

Already tried it.
Did not work.
It has nothing to do with caching.

@divine
Copy link

divine commented Dec 21, 2020

Hello,

Well, if version 6.16.0 was installed then klona would be here, however, it's not found.

Basically could you please run yarn install or npm install? Clearing .nuxt cache might help also.

Thanks!

@provok-me
Copy link
Author

provok-me commented Dec 21, 2020

  • yarn remove nuxt-i18n
  • yarn add -S nuxt-i18n
  • Removed ./node_modules
  • Removed ./cache
  • Removed ./.nuxt
  • yarn install

Still not working.
klona is present in ./node_modules... but without the "full" directory within it.

Here's klona package.json's exports section.
Capture d’écran 2020-12-22 à 00 17 54

They reference the export of the "full" directory which contains a js file needed to run nuxt-i18n (since you import that js file in ./.nuxt/nuxt-i18n/plugin.main.js).

The files klona/full/index.mjs and klona/full/index.js are not there in the v6.16.0 of nuxt-i18n, thus it doesn't work.

@rchl
Copy link
Collaborator

rchl commented Dec 21, 2020

Check this: https://unpkg.com/browse/klona@2.0.4/

There is something wrong with your system/setup. Possibly with the yarn/npm cache.

@divine
Copy link

divine commented Dec 21, 2020

I've just spinned up new nuxt app and I can't recreate the problem that you're having.

@provok-me
Copy link
Author

provok-me commented Dec 21, 2020

I think that I have a clue.

Inside ./node_modules/nuxt-i18n there is klona@2.0.4.
There is klona@1.1.2 at ./node_modules/klona.

Since the file importing klona is ./.nuxt/nuxt-i18n/plugin.main.js, I think that it searches for "full" inside ./node_modules/klona@1.1.2 and not ./node_modules/nuxt-i18n/klona@2.0.4.

Would that be possible?
Wouldn't peerDependencies solve the whole thing?

divine added a commit to divine/i18n-module that referenced this issue Dec 22, 2020
@divine
Copy link

divine commented Dec 22, 2020

I think that I have a clue.

Inside ./node_modules/nuxt-i18n there is klona@2.0.4.
There is klona@1.1.2 at ./node_modules/klona.

Since the file importing klona is ./.nuxt/nuxt-i18n/plugin.main.js, I think that it searches for "full" inside ./node_modules/klona@1.1.2 and not ./node_modules/nuxt-i18n/klona@2.0.4.

Would that be possible?
Wouldn't peerDependencies solve the whole thing?

I have just reproduced it locally. I've installed klona@1.1.2 and after added nuxt-i18n. It throws errors on compile because klona is an older version which doesn't contain full directory https://github.com/lukeed/klona/releases/tag/v2.0.0

I've moved klona to peerDependencies as It's just throwing warning but not installing newer version:

warning " > nuxt-i18n@6.16.0" has unmet peer dependency "klona@^2.0.4".

@rchl what do you think? Should we move to peerDependencies or just keep it as it is.

Basically, it doesn't resolve the issue, @Alphability you need to upgrade your local klona version to ^2.

Thanks!

@provok-me
Copy link
Author

provok-me commented Dec 22, 2020

Since some of nuxt-i18n code runs outside of the package itself I recommend you to install the dependencies needed on the outside as peerDependencies.
That's what they're for if you read yarn or npm documentation.

Those dependencies are not auto-installed.
So, you'll need to tell your users to install them.

Your setup section should just look like this:

# yarn
yarn add nuxt-i18n klona@^2.0.4

# npm
npm i nuxt-i18n klona@^2.0.4

@rchl
Copy link
Collaborator

rchl commented Dec 22, 2020

It does feel like it would make sense for modules to specify dependencies that they use in plugins as peer dependencies. It's not a normal practice though, as far as I can tell, and it would be kinda unusual to do that.

Not to mention that requiring the user to manage dependencies himself would make things a lot less user-friendly and potentially error-prone. For example, a module can enforce certain dependency versions while it's not as straight-forward with peer dependencies. It can still specify which version should be used but if the user doesn't match that, it will only result in an easy-to-miss warning when installing dependencies.

As for this particular problem, you can of course just install klona dependency manually (without having it in peer dependencies), and then that version will be used and things will work for nuxt-i18n. Only that you risk problems with that other code that requires klona 1.x (especially if it's used from a plugin of another module). And that problem would apply even if klona would be specified in peerDependencies. So there is no perfect solution really.

@rchl
Copy link
Collaborator

rchl commented Dec 22, 2020

@pi0 @atinux This is an interesting problem and I wonder if you have any take on it.

@provok-me
Copy link
Author

provok-me commented Dec 22, 2020

Not to mention that requiring the user to manage dependencies himself would make things a lot less user-friendly and potentially error-prone. For example, a module can enforce certain dependency versions while it's not as straight-forward with peer dependencies.

I totally understand your point.

From my perspective the real less user friendly thing and error prone to do is to let open the possibility to get an error like this with complex projects.

The more dependencies you have and/or need the more likely you are to get this error... and the more likely to waste a lot of time trying to understand where it comes from.

Yes peerDependencies are scary... but they're here for a reason.
They're not the problem, they're here to solve this particular one.

It can still specify which version should be used but if the user doesn't match that, it will only result in an easy-to-miss warning when installing dependencies.

In my opinion, It is never a bad idea to make people accountable (especially developers) for what they do.

@atinux @pi0 what is your opinion about this pretty interesting matter?

@rchl
Copy link
Collaborator

rchl commented Dec 22, 2020

peerDependencies doesn't fix the problem in case two modules require the same dependency but in different, incompatible versions. The user can only install a single version.

@provok-me
Copy link
Author

Yeah that is a problem... but this problem comes directly from the fact that we can add plugins with a module.

Thanks for the chat @rchl, this is really interesting! 🙏

I am eager to read from Atinux and pi0 on this!

@pi0
Copy link

pi0 commented Dec 22, 2020

Hi @rchl. You can resolve full path of klona on behalf of module for exact version that requires:

nuxt.options.alias['klona'] = require.resolve('klona/lite')
// Alt: nuxt.options.alias['~i18n-klona'] = require.resolve('klona/lite')

For a longer answer, I'm compiling runtime instead of emitting as plugin template for image and auth modules and adding this pattern with new module template and nuxt/kit. This resolves implicit dependency issues as well as making runtime lintable/typed.

@ABleas
Copy link

ABleas commented Jan 5, 2021

I found this issue when doing an upgrade on dependencies for my project.

I could install klona/full as a peerDependency as suggested, but

  • I don't want to know what it is, nor do I much care.
  • The error suggests this is a dependency of nuxt-i18n, why do I have to do extra steps to make this package work?

Just from a naive, dumb user point of view, should this not be resolved on the i18n module side of things?

@provok-me
Copy link
Author

provok-me commented Jan 5, 2021

  • I don't want to know what it is, nor do I much care.

@ABleas
THE WORLD IS BURNING BECAUSE OF PEOPLE THAT DON'T WANT TO KNOW OR DON'T REALLY CARE 👏 👏 👏

Just because a 404 is not as lethal as a bridge collapsing doesn't mean that you're free to stop learning how to do your job 😘

@ABleas
Copy link

ABleas commented Jan 5, 2021

Just because a 404 is not as lethal as a bridge collapsing doesn't mean that you're free to stop learning how to do your job 😘

Sorry for sounding gruff. I appreciate that it's important to somebody, but it isn't my job to understand everything that goes on under the hood of this wonderful module. That would make my job impossible!

I should also say, I am really happy with nuxt-i18n. It is a pleasure to use.

@daishizenSensei
Copy link

daishizenSensei commented Jan 13, 2021

Hello, it seems that this issue still be here. We've update to the last release and have this error :
Failed to compile with 1 errors
This dependency was not found:

  • ~i18n-klona in ./.nuxt/nuxt-i18n/plugin.main.js
    To install it, you can run: npm install --save ~i18n-klona

@daishizenSensei
Copy link

Of course npm install --save ~i18n-klona doesn't work

@rchl
Copy link
Collaborator

rchl commented Jan 13, 2021

Delete node_modules and try again:

rm -rf node_modules
npm i

@daishizenSensei
Copy link

It's working, thank you :)

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

Successfully merging a pull request may close this issue.

6 participants