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

Installing a local optionalDependency leads to an non-existing file error #7678

Open
kristian opened this issue Nov 8, 2019 · 5 comments
Open

Comments

@kristian
Copy link

kristian commented Nov 8, 2019

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When installing a package with yarn, which has an optionalDependency to a local file, which is non-existant then yarn install fails with an error:

package.json

...
"optionalDependencies": {
   "anything_local": "file:./nonexistent_folder"
}
...

Leads to the error:

error Package "anything_lcocal" refers to a non-existing file '".../nonexsistent_folder"'.

If the current behavior is a bug, please provide the steps to reproduce.

yarn install any package with on optional local dependency which the folder does not exist.

What is the expected behavior?

As the dependency is optional anyways, the expected behaviour would be that only a warning, is logged and the install command ends with an success.

@graphan
Copy link

graphan commented Jan 11, 2020

I would go even further and make it work also for dependencies:

...
"dependencies": {
   "react-native-webview": "file:./../node_modules/react-native-webview"
}
...

Why?

Because it is a very important feature for linking React Native Libraries.
Let's imagine that you have the following folders structure:

- components
- native_app
- node_modules

If node_modules contains a React Native Library hoisted from components and native_app contains a React Native App, then you can link the library with the app running:
cd native_app && react-native link react-native-webview

But, this will only work when we keep package.json as above. That means that this is a vicious cycle, because during installation "file:./../node_modules/react-native-webview" is not existent yet.

Thus, I think it is a very important feature to provide a way to bypass checking local files in general, not only for optionalDependencies.

@GitPaulo
Copy link

I'm having the same issue. Having this feature would help a lot when working with libraries that require local dependencies during development.

@celeroncoder
Copy link

I'm having the same issue. It happened with downloading the Prisma client which led to the following error:

error Package "chokidar2" refers to a non-existing file '"root/chokidar2"'.

I deleted the node_modules directory and rerun the command but having the same exact issue/

@debragail
Copy link

debragail commented Feb 5, 2023

I'm having this issue as well with yarn install


yarn install
<1s
+ yarn install
yarn install v1.22.19
[1/4] Resolving packages...
error Package "components" refers to a non-existing file '"/opt/atlassian/pipelines/agent/build/components/dist"'.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@kristian
Copy link
Author

kristian commented Feb 5, 2023

This was meanwhile answered by @arcanis in yarnpkg/berry#4306 (comment), Yarn actually requires to resolve optional dependencies for reasons of a consistent resolution. Checkout https://github.com/kristian/yarn-plugin-better-optional for a potential workaround. I have never tested it with local files though.

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

5 participants