Skip to content

Doesn't work in monorepo when modules are hoisted #199

Closed

Description

@jlongster

I'm using yarn workspaces and the entry point for the electron is inside one of the packages. The package is called desktop-electron, and sits beside other modules like core and design. core is depended on the most, and yarn will make it available to all the other packages by hoisting it as a dep on the top-level. So the structure looks like this:

- node_modules/core (symlink, I think, to core in packages/)
- packages/
   - core
   - design
   - desktop-electron

If I cd packages/desktop-electron and do ncc build index.js -o build, where index.js is the entry point to my electron app, I get the following error:

ERROR in ./index.js 77:11-59
Module not found: Error: Can't resolve 'core/lib-node/platform/server/fs' in '/Users/james/projects/actual/packages/desktop-electron'

when it definitely exists in the root node_modules

Activity

  1. jlongster commented on Dec 28, 2018

    @jlongster
    Author

    Nevermind, I think it's because the file it's trying to use is fs.electron.js, and I'm using custom extensions to load different files on different platforms. I have other issues that I'll try to dig into and file later, if I have time to try this again.

  2. migueloller commented on Aug 13, 2019

    @migueloller

    This seems to still be an issue! ncc warns that the module couldn't be found and the build subsequently fails when run.

    ncc: Module directory "..." attempted to require "..." but could not be resolved, assuming external.
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions