Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: invalid path for export in package.json (v 5.0.0)#164

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cristianoliveira wants to merge2 commits intodevelopit:main
base:main
Choose a base branch
Loading
fromcristianoliveira:main

Conversation

cristianoliveira
Copy link

First of all, thanks for this library! We have been using it for quite a long time, and it works like a charm.

Description

It seems that there are invalid values exported in the package.jsonhttps://github.com/developit/unfetch/blob/main/package.json#L18

It causes issue while usingunfetch as a module, for instance, we use webpack and once upgraded to 5.0.0 it started to break the build with the given (not so clear, to say the least) error:

ERROR in ./src/index.js 1:0-30Module not found: Error: Can't resolve 'unfetch' in '/Users/user/dev/unfetch-issue-demo/src'resolve 'unfetch' in '/Users/user/dev/unfetch-issue-demo/src'  Parsed request is a module  using description file: /Users/user/dev/unfetch-issue-demo/package.json (relative path: ./src)    Field 'browser' doesn't contain a valid alias configuration    resolve as module      /Users/user/dev/unfetch-issue-demo/src/node_modules doesn't exist or is not a directory      looking for modules in /Users/user/dev/unfetch-issue-demo/node_modules        single file module          using description file: /Users/user/dev/unfetch-issue-demo/package.json (relative path: ./node_modules/unfetch)            no extension              Field 'browser' doesn't contain a valid alias configuration              /Users/user/dev/unfetch-issue-demo/node_modules/unfetch is not a file            .tsx              Field 'browser' doesn't contain a valid alias configuration              /Users/user/dev/unfetch-issue-demo/node_modules/unfetch.tsx doesn't exist            .ts              Field 'browser' doesn't contain a valid alias configuration              /Users/user/dev/unfetch-issue-demo/node_modules/unfetch.ts doesn't exist            .js              Field 'browser' doesn't contain a valid alias configuration              /Users/user/dev/unfetch-issue-demo/node_modules/unfetch.js doesn't exist            .jsx              Field 'browser' doesn't contain a valid alias configuration              /Users/user/dev/unfetch-issue-demo/node_modules/unfetch.jsx doesn't exist        existing directory /Users/user/dev/unfetch-issue-demo/node_modules/unfetch...

Demo

Here you can see an example of this issue:
https://github.com/cristianoliveira/unfetch-issue-demo

Solution

After pointing tosrc/index.mjs it started to compile again and it is working as expected. 😄

Let me know if this is the right solution.

Relates to

#163
#162

lihbr, EvHaus, lsdsjy, jnachtigall, and christowiz reacted with thumbs up emojiNickMcBurney and pheuberger reacted with eyes emoji
@cristianoliveira
Copy link
Author

cristianoliveira commentedFeb 10, 2023
edited
Loading

For those who use webpack and want a quick fix, while this isn't correctly addressed, you can create an alias and point to the correct file:

In the webpack.config.js include:

resolve:{alias:{'unfetch':path.resolve(__dirname,'node_modules/unfetch/dist/unfetch.mjs'),},},
ediblecode, danielyang-bnz, and Psychosynthesis reacted with thumbs up emojiilbertt reacted with heart emoji

Co-authored-by: Ryan Christian <33403762+rschristian@users.noreply.github.com>
@rschristian
Copy link

Looks correct to me!

@ayZagen
Copy link

ayZagen commentedMar 27, 2023
edited
Loading

@rschristian@developit pinging in case you have forgotten to approve

@rschristian
Copy link

Sorry, not a maintainer, my approval does nothing. Just a drive-by suggestion as I ran into this and was seeing if anyone had submitted a fix yet.

ayZagen reacted with thumbs up emoji

@denizsult
Copy link

For those who use webpack and want a quick fix, while this isn't correctly addressed, you can create an alias and point to the correct file:

In the webpack.config.js include:

resolve:{alias:{'unfetch':path.resolve(__dirname,'node_modules/unfetch/dist/unfetch.mjs'),},},

Workes fine. Thanks

cristianoliveira and nodir-js reacted with thumbs up emoji

jonathansick added a commit to lsst-sqre/squareone that referenced this pull requestAug 15, 2023
This is pending a fix to a how unfetch 5 exports its files, e.g.developit/unfetch#164
jonathansick added a commit to lsst-sqre/squareone that referenced this pull requestAug 16, 2023
This is pending a fix to a how unfetch 5 exports its files, e.g.developit/unfetch#164
@Skopea
Copy link

Can this be merged? I really need this change since in cannot start storybook in my project, Thanks for fixing this! 🥳

@alinasir85
Copy link

@rschristian , Kindly approve & merge it

@rschristian
Copy link

@rschristian , Kindly approve & merge it

#164 (comment)

@alinasir85
Copy link

@rschristian , Kindly approve & merge it

#164 (comment)

But its showing that your review is pending..

Screenshot 2023-10-24 at 12 47 32 AM

@rschristian
Copy link

Doesn't matter -- GitHub's UI is a bit weird there for sure, but the approval of non-maintainers does nothing. You'd see a "collaborator" badge (I think) next to my name if I was able to approve and merge.

alinasir85 reacted with thumbs up emoji

@alinasir85
Copy link

@developit ?

@katerberg
Copy link

This would be really nice to have merged since it currently is unusable invite without a manual override.

For anyone else usingvite, adding a resolve alias solved this for now:

defineConfig({  resolve: {    alias: {      unfetch: path.resolve(__dirname, "node_modules/unfetch/dist/unfetch.mjs"),    }  }})
jnachtigall reacted with thumbs up emoji

@tdacu
Copy link

tdacu commentedNov 16, 2023
edited
Loading

This would be really nice to have merged since it currently is unusable invite without a manual override.

=> Failed to build the preview
ReferenceError: path is not defined

And if I'm importing

import path from 'path';

I'm still getting
Error: Failed to resolve entry for package "unfetch". The package may have incorrect main/module/exports specified in its package.json.

pheuberger added a commit to pheuberger/toucan-sdk that referenced this pull requestNov 29, 2023
Without this patch people were experiencing problems when bundling theSDK. See issueToucanProtocol#95ToucanProtocol#95The problem is that `isomorphic-unfetch` 4.0.2 upgraded to `unfetch`5.0.0 which currently has an issue with their module exports leading toan error when bundling the lib itself or any other lib that depends on`unfetch`.See this PR for more information:developit/unfetch#164Once this PR is merged we can go back to the latest `isomorphic-unfetch`version.
pheuberger added a commit to pheuberger/toucan-sdk that referenced this pull requestNov 29, 2023
Without this patch people were experiencing problems when bundling theSDK. See issueToucanProtocol#95ToucanProtocol#95The problem is that `isomorphic-unfetch` 4.0.2 upgraded to `unfetch`5.0.0 which currently has an issue with their module exports leading toan error when bundling the lib itself or any other lib that depends on`unfetch`.See this PR for more information:developit/unfetch#164Once the PR above is merged we can go back to the latest `isomorphic-unfetch`version.
@tim-kilian
Copy link

Can someone merge this, please?

unflxw added a commit to appsignal/appsignal-javascript that referenced this pull requestApr 23, 2024
An issue with `unfetch@5`, depended on by `isomorphic-unfetch@4.0.2`,breaks bundling with tools such as `esbuild` and `webpack`:developit/unfetch#164
@alopix
Copy link

Any chance this can get merged and published? Lots of bundler workarounds required right now 😅

RoyRao2333 reacted with thumbs up emoji

@katerberg
Copy link

@developit is this possible to merge? Not sure on the status on the library, but this one would be a really helpful fix.

humitos reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@narthurnarthurnarthur approved these changes

@SkopeaSkopeaSkopea approved these changes

@rschristianrschristianAwaiting requested review from rschristian

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

11 participants
@cristianoliveira@rschristian@ayZagen@denizsult@Skopea@alinasir85@katerberg@tdacu@tim-kilian@alopix@narthur

[8]ページ先頭

©2009-2025 Movatter.jp