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

Not compatible with PNPM #32

Open
hughlv opened this issue May 9, 2022 · 14 comments
Open

Not compatible with PNPM #32

hughlv opened this issue May 9, 2022 · 14 comments
Assignees
Labels
consider enhancement New feature or request
Milestone

Comments

@hughlv
Copy link

hughlv commented May 9, 2022

I'm encountering this issue when switching from yarn to pnpm:

https://nextjs.org/docs/messages/module-not-found
wait  - compiling...
error - ./node_modules/.pnpm/[email protected]_c0abbb53577d424fe320649841fdc7d4/node_modules/next-export-i18n/index.js:5:0
Module not found: Can't resolve './../../i18n/index.js'

By reading the source code, the issue is that next-export-i18n assumed it would always be located as <project_folder>/node_modules/next-export-i18n. This is no longer true with pnpm, as it utilized the hard link feature so next-export-18n would be in another location.

I'm still investigating pnpm whether there is solution to make certain package as an exception. No clue yet...

@martinkr
Copy link
Owner

Hey!

Thank you for your contribution. Unfortunately, I never used pnpm. I need to investigate this as well...

Cheers!

@hughlv
Copy link
Author

hughlv commented May 22, 2022

Thanks for your reply.

One possible solution you can consider is to pass the config object during the initialization, comparing to current implementation this could eliminate the assumption of the file naming and location.

Thanks for your great project.

@martinkr
Copy link
Owner

Hey!

Planning to implement this in the next release.
If you like, you can also raise a pull request :)

Cheers!

@martinkr martinkr self-assigned this May 26, 2022
@martinkr martinkr added the enhancement New feature or request label May 26, 2022
@martinkr martinkr added this to the 3.0.0 milestone May 26, 2022
@hughlv
Copy link
Author

hughlv commented May 27, 2022

Great. Looking forward to that.

@dmylian
Copy link

dmylian commented Sep 14, 2022

Hey, looks like the expectation of locale folder location makes it incompatible with the monorepo setup as well, where you have the i18 folder not in ./../../i18n/index.js, but in ./../../apps/consumer-app/i18n/.
The compat fix for pnpm would probably make this problem go away. As @hughlv noted, hardcoding the config path is probably a bit dangerous. Any chance you found a workaround?

@martinkr martinkr modified the milestones: 3.0.0, 4.0.0 Sep 30, 2022
@mihamor
Copy link

mihamor commented Feb 21, 2023

@hughlv hey, im also experiencing that with pnpm
the solutions is you can patch package with pnpm patch https://pnpm.io/cli/patch and set
var I18N = require('./../../i18n/index.js'); path as you want.
for me i've had to add few extra "parent paths" ../

@JimmyLv
Copy link

JimmyLv commented Apr 12, 2023

I also met this issue, :(

thanks to @mihamor , this is my solution, (bash history):

 1968  pnpm patch next-export-i18n@^2.1.0
 1969  subl /private/var/folders/zv/jzl76zs903z4wdj_fdskc92r0000gn/T/730a0dd5dbc8fa11edad43fd784b62dd
 1970  cd ./node_modules/.pnpm/[email protected]_pxeeag5fab3ngpbhgu2rjk6nzy_yucv4tfv7v7nrkw2uguegj6e7e/node_modules/next-export-i18n
 1971  cd ./../../../../../i18n
 1974  pnpm patch-commit /private/var/folders/zv/jzl76zs903z4wdj_fdskc92r0000gn/T/730a0dd5dbc8fa11edad43fd784b62dd

this is the final generated patch file:

diff --git a/index.js b/index.js
index 79f31c56e96382496d9ba42f7fa4da736ecfcb47..de12b2889ff1c8bc2480f818c51328b5b1b14109 100644
--- a/index.js
+++ b/index.js
@@ -2,7 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
 
 var router = require('next/router');
 var React = require('react');
-var I18N = require('./../../i18n/index.js');
+var I18N = require('./../../../../../i18n/index.js');
 var Mustache = require('mustache');
 
 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

and package.json

"pnpm": {
    "patchedDependencies": {
      "[email protected]": "patches/[email protected]"
    }
  }

@martinkr martinkr modified the milestones: 4.0.0, 3.2.0 Dec 15, 2023
@arcanjosaddi
Copy link

Any updates?

@SalahAdDin
Copy link

@martinkr we are using pnpm as well. This makes it impossible for us to work with this package, sad.

@martinkr
Copy link
Owner

Hi @SalahAdDin,

I appreciate your interest in this package. Unfortunately, I don't use ppm in my projects. Hence, I need to gain practical experience with this package manager's concepts.

If you would consider adding Pnpm support, I would happily merge your PR for the next release.

Looking forward to your PR,

Martin

@SalahAdDin
Copy link

I also met this issue, :(

thanks to @mihamor , this is my solution, (bash history):

 1968  pnpm patch next-export-i18n@^2.1.0
 1969  subl /private/var/folders/zv/jzl76zs903z4wdj_fdskc92r0000gn/T/730a0dd5dbc8fa11edad43fd784b62dd
 1970  cd ./node_modules/.pnpm/[email protected]_pxeeag5fab3ngpbhgu2rjk6nzy_yucv4tfv7v7nrkw2uguegj6e7e/node_modules/next-export-i18n
 1971  cd ./../../../../../i18n
 1974  pnpm patch-commit /private/var/folders/zv/jzl76zs903z4wdj_fdskc92r0000gn/T/730a0dd5dbc8fa11edad43fd784b62dd

this is the final generated patch file:

diff --git a/index.js b/index.js
index 79f31c56e96382496d9ba42f7fa4da736ecfcb47..de12b2889ff1c8bc2480f818c51328b5b1b14109 100644
--- a/index.js
+++ b/index.js
@@ -2,7 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
 
 var router = require('next/router');
 var React = require('react');
-var I18N = require('./../../i18n/index.js');
+var I18N = require('./../../../../../i18n/index.js');
 var Mustache = require('mustache');
 
 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

and package.json

"pnpm": {
    "patchedDependencies": {
      "[email protected]": "patches/[email protected]"
    }
  }

what about opening a MR?

@SalahAdDin
Copy link

@hughlv hey, im also experiencing that with pnpm the solutions is you can patch package with pnpm patch https://pnpm.io/cli/patch and set var I18N = require('./../../i18n/index.js'); path as you want. for me i've had to add few extra "parent paths" ../

it would be good then to update the package to use aliases...

@martinkr
Copy link
Owner

martinkr commented Feb 1, 2024

Hi @SalahAdDin,

Would you consider providing a set of instruction of how to achieve pnpm compatibility? In the Code Snippet, we're referring specific version numbers, hence it would not be feasible to add this snippet directly to the codebase.

Thank you for your contribution!

Cheers!

@SalahAdDin
Copy link

SalahAdDin commented Feb 1, 2024

Hi @SalahAdDin,

Would you consider providing a set of instructions on how to achieve pnpm compatibility? In the Code Snippet, we're referring to specific version numbers, hence it would not be feasible to add this snippet directly to the codebase.

Thank you for your contribution!

Cheers!

It was @JimmyLv who made the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consider enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants