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

NPM workspace and monorepo support #796

Open
nathanscully opened this issue Nov 22, 2023 · 0 comments
Open

NPM workspace and monorepo support #796

nathanscully opened this issue Nov 22, 2023 · 0 comments

Comments

@nathanscully
Copy link

I attempted to use dream2nix on an npm workspace managed monorepo and ran into an issue on how to manage local package dependencies. I used the nodejs-project as a base which works fine in a workspace if there are no dependencies.

I am guessing I need to build the dependency package as a derivation and make it available as the root package build but can't see any examples or documentation on the best way to accomplish this.

I've set up an example repository here: https://github.com/nathanscully/dream2nix-npm-monorepo

Structure

- flake.nix
- package.json
- /apps
    - /myapp 
      - default.nix
      - app.ts
      - package.json <-- has a workspace dependency on  "packages/adder"
    - /myapp-nodep
      - default.nix
      - app.ts
      - package.json
- /packages
  - /adder 
    - index.ts
    - package.json
  

I can run the 'nodep' version ok:

nix run .#myapp-nodep  
> Hello, World!

But on the 'dep' version:

nix run .#myapp 
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@d2n%2fadder - Not found
npm ERR! 404 
npm ERR! 404  '@d2n/adder@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

So it looks like its trying to fetch the workspace package from NPM.

Any advice or tips on how to package this up properly?

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

1 participant