-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Error during "yarn pack": Cannot find module "." #6794
Comments
I tracked that piece of code to this https://github.com/stefanpenner/hash-for-dep/blob/master/lib/pkg.js . It looks like webpack tries to resolve that require statement and that is not right. |
I'd personnally advise you not to use bundled dependencies, ever, whether it's on Yarn or any other package manager. They are a badly designed feature 😕 |
Ok, thanks for the advice. I was trying to make a custom piece of code that did exactly this and then I found that yarn had this functionality already built-in. It was sad to find out that it doesn't work :( Still, it would be great if this bug gets fixed, because the |
I ran into this issue. |
And if you fix the broken webpack require, yarn will pack the package without including any @payload Would you be able to share your custom solution? |
@GusGold unfortunately not. It's actually fun to write such a bundle script, but you could also just fairly straight forward write a script which does all the manual steps hardcoded. npm pack relevant dependencies, create a zip archive, put all the files and dependencies as tgz in, rewrite package.json dependencies to use those tgz. |
No worries, @payload . I started writing a very similar solution last night, but was trying to emulate yarn's cache and then using I hadn't considered rewriting the package.json to look directly for the tgz, thanks! |
This improves the hack which gets rid of protagonist (i.e. C++ compilation of drafter, the API Blueprint parser). When we moved dredd-transactions to the monorepo, where dependencies are managed by yarn workspaces, the hack to get rid of protagonist stopped to work. The hack relies on 'bundledDependencies', but those stopped to work. 'npm pack' cannot find the dependencies to bundle if they're in the root 'node_modules' directory. 'yarn pack' doesn't work either, it has bugs and it doesn't support 'bundledDependencies' or the workspaces very well - see yarnpkg/yarn#6794 This change overcomes the limitation by improving the prepack.js script. It now iterates over the 'bundledDependencies' and symlinks them to the local 'node_modules' directory where 'npm pack' can pick them up. After packing is done, there's a new postpack.js script, which makes sure the symlinks get cleaned up. The resulting .tgz then contains the dependencies bundled - without protagonist.
This improves the hack which gets rid of protagonist (i.e. C++ compilation of drafter, the API Blueprint parser). When we moved dredd-transactions to the monorepo, where dependencies are managed by yarn workspaces, the hack to get rid of protagonist stopped to work. The hack relies on 'bundledDependencies', but those stopped to work. 'npm pack' cannot find the dependencies to bundle if they're in the root 'node_modules' directory. 'yarn pack' doesn't work either, it has bugs and it doesn't support 'bundledDependencies' or the workspaces very well - see yarnpkg/yarn#6794 This change overcomes the limitation by improving the prepack.js script. It now iterates over the 'bundledDependencies' and symlinks them to the local 'node_modules' directory where 'npm pack' can pick them up. After packing is done, there's a new postpack.js script, which makes sure the symlinks get cleaned up. The resulting .tgz then contains the dependencies bundled - without protagonist.
Since it's impossible to test this now that |
Not sure if this particular issue is fixable at all, but ran into it setting up some simple testing to (hopefully) contribute a fix for #5998. With yarn v1 sticking around as the "npm compatible" option compared to yarn v2 / "berry", maybe we can start fixing up some of these |
Closing as we've completely removed support for |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running the command
yarn pack
throws an error if there are any packages inbundledDependencies
I tracked the bug to this section of code, more specifically the line with the
thePackage
assignIf the current behavior is a bug, please provide the steps to reproduce.
"bundledDependencies": ["typescript"]
to the package.jsonWhat is the expected behavior?
An archive is created containing the specified module.
Please mention your node.js, yarn and operating system version.
Node 8.12.0
Yarn 1.12.3
MacOS 10.14.1
The text was updated successfully, but these errors were encountered: