GithubHelp home page GithubHelp logo

Comments (7)

quisido avatar quisido commented on June 10, 2024 2

This looks like an issue with "MetroJS bundler" not supporting .cjs extensions natively.

https://stackoverflow.com/questions/60124435/however-this-package-itself-specifies-a-main-module-field-that-could-not-be-r

Looks like you need to edit your existing metro.config.js file (or make one if it does not already exist), then add cjs to the resolver.sourceExts array.

Let me know if the above StackOverflow solutions don't unblock you. I can see what else I can do, but I am ultimately relunctant to change the file extension of the bundled CommonJS file, because the different file extension is a requirement for newer versions of Node to distinguish CommonJS from ESM files in the same package.

from reactn.

minuitagency avatar minuitagency commented on June 10, 2024 1

Hi Charles,

Thanks for the library, could you release an update to reactn that has the fixed use-force-update dependency ? We use reactn in a LOT of projects...

Thanks,

Théo

from reactn.

quisido avatar quisido commented on June 10, 2024

I'm not positive why this is occurring, but thank you for bringing it to my attention. The file definitely exists.

I have historically been able to successfully assign main as the CommonJS export and module as the ESM export. For some reason, your build is expecting an ESM export (probably because your application is ESM and/or because use-force-update uses the "type": "module" property).

I believe a build tool that is looking for an ESM bundle should be using the module property instead of the main property. Nonetheless, I will attempt to resolve this by using exports instead.

I'm pushing 1.0.10 right now. Give it a few hours to flow through CI/CD and for NPM caches to clear. Then update the nested dependency. I don't know the NPM command offhand, but the yarn command would be yarn up -R use-force-update. You should also be able to do npm uninstall reactn && npm install reactn --save to get a similar effect, as I assume use-force-update is not being locked by any other dependency.

Let me know if 1.0.10 does not resolve this issue for you, and I'll continue the investigation. :)

EDIT: Here is the link to the CI/CD for [email protected]

from reactn.

leachus avatar leachus commented on June 10, 2024

Thanks for the quick response.

I’ve been testing the same project this was reported on, but on Android. The workaround of updating the package.json fixes the problem when doing a development build, but doesn’t seem to help on a production build.

This afternoon I updated our problem project with your new version 1.0.10 of use-force-update and tried again. The build is still failing.

Here’s the relevant section of the build log:
[stderr]
error While trying to resolve module use-force-update from file /home/expo/workingdir/build/node_modules/reactn/build/use-dispatch.js, the package /home/expo/workingdir/build/node_modules/use-force-update/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs. Indeed, none of these files exist:
[stderr]

  • /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
    [stderr]
  • /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json).
    Error: While trying to resolve module use-force-update from file /home/expo/workingdir/build/node_modules/reactn/build/use-dispatch.js, the package /home/expo/workingdir/build/node_modules/use-force-update/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs. Indeed, none of these files exist:
  • /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
  • /home/expo/workingdir/build/node_modules/use-force-update/dist/cjs/index.cjs/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
    at DependencyGraph.resolveDependency (/home/expo/workingdir/build/node_modules/metro/src/node-haste/DependencyGraph.js:436:17)
    at Object.resolve (/home/expo/workingdir/build/node_modules/metro/src/lib/transformHelpers.js:317:42)
    at resolve (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:629:33)
    at /home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:645:26
    at Array.reduce ()
    at resolveDependencies (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:644:33)
    at /home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:329:33
    at Generator.next ()
    at asyncGeneratorStep (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:137:24)
    at _next (/home/expo/workingdir/build/node_modules/metro/src/DeltaBundler/traverseDependencies.js:159:9)
    info Run CLI with --verbose flag for more details.

Task :app:bundleReleaseJsAndAssets FAILED
[stderr]
FAILURE: Build failed with an exception.

Thanks for taking a look at this.

from reactn.

leachus avatar leachus commented on June 10, 2024

I edited metro.config.js using info from the Stack Overflow link you supplied and from https://docs.expo.dev/guides/customizing-metro/. The build is working well now, without me needing to futz with the use-force-update package.

Really appreciate your quick help in figuring this out.

from reactn.

purplecones avatar purplecones commented on June 10, 2024

Hi Charles,

Thanks for the library, could you release an update to reactn that has the fixed use-force-update dependency ? We use reactn in a LOT of projects...

Thanks,

Théo

This is blocking us as well. Is there anything we can do on our side to address this until it is resolved in the library?

from reactn.

quisido avatar quisido commented on June 10, 2024

@minuitagency @purplecones Have you tried the configuration change for Metro bundler? As it was initially reported, this is a problem with the Metro bundler, not the dependency, and the fix has already been included in this thread chain.

from reactn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.