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

Install npm dependencies after cloning #51

Closed
1 task done
pi0 opened this issue Dec 5, 2022 · 17 comments
Closed
1 task done

Install npm dependencies after cloning #51

pi0 opened this issue Dec 5, 2022 · 17 comments
Assignees

Comments

@pi0
Copy link
Member

pi0 commented Dec 5, 2022

Describe the feature

We should support an optional flag to support installing template dependencies after cloning. This gives close functionality to a layer to an npm package.

Additional information

  • Would you be willing to help implement this feature?
@pi0
Copy link
Member Author

pi0 commented Dec 5, 2022

For context, this feature is required for Nuxt Layers Extending (nuxt/nuxt#13367). Install after the clone is the most straightforward way. However, there are more ingenious ways such as generating a stub package.json and add it as a dependency to the main project. These are beyond c12 and should be experimented on nuxt but worth noting here.

@pi0
Copy link
Member Author

pi0 commented Dec 6, 2022

Linking issue unjs/giget#6

@marr
Copy link

marr commented Aug 24, 2023

The nuxt layer issue seems more complicated than installing after cloning. The issue of missing dependencies happens even when not using git references. Ie, if I point my extends to a relative file path, like ../layer1, the deps installed there are not found by the parent app.

@pi0
Copy link
Member Author

pi0 commented Aug 24, 2023

@marr this is something we might want to investigate on nuxt (and nitro) side. framework is supposed to automatically add {layer}/node_modules to modulesDir[] configuration.

@pi0
Copy link
Member Author

pi0 commented Aug 24, 2023

BTW now we have stable nypm if anyone wants to support it as an optional feature PR is welcome 👍🏼

@francoisauclair911
Copy link

Just checking if there is some progress made on this ?
Thank you!

@pi0
Copy link
Member Author

pi0 commented Oct 9, 2023

@francoisauclair911 Yes it is on my todo list to add opt-in feature 👍🏼

@madsh93
Copy link

madsh93 commented Oct 12, 2023

@pi0 this is very exciting. It will be much easier to manage layers this way.

@pi0
Copy link
Member Author

pi0 commented Oct 13, 2023

Also related: #109

@madsh93
Copy link

madsh93 commented Oct 13, 2023

If i I understand it correctly then using layers with the GitHub strategy it is now fixed? Would that mean that the last remaining strategy is if using monorepo @pi0 ?

@pi0
Copy link
Member Author

pi0 commented Oct 19, 2023

with #112 and https://github.com/unjs/c12/releases/tag/v1.5.1, now we are one step away from supporting this (unjs/giget#6)

@pi0
Copy link
Member Author

pi0 commented Dec 29, 2023

A shortcut for install is added via #126. This feature is undocumented for now until testing more. Feedbacks more than welcome!

@9M6
Copy link

9M6 commented May 21, 2024

@pi0 the issue pointed out by @marr still persists. I have a layer which I am extend:['../layer'] from a parent directory, but the dependencies are not included. When I manually added: modulesDir: ["../layer/node_modules"], it magically started kind of working.

@9M6
Copy link

9M6 commented May 21, 2024

@pi0 yes, does not install. Do I need to do npm install or npm build/dev?

@pi0
Copy link
Member Author

pi0 commented May 21, 2024

@9M6 if you are sure the dependencies will be installed, it might be bug in nuxt that does not extends layer node_modules. In which case i would suggest to follow up via an issue in nuxt repostiroy 🙏🏼

@aurelioth
Copy link

@pi0 Can you check my comment here nuxt/nuxt#26479 ? Hope it makes sense for you.

@vis97c
Copy link

vis97c commented Jun 3, 2024

@pi0 the issue pointed out by @marr still persists. I have a layer which I am extend:['../layer'] from a parent directory, but the dependencies are not included. When I manually added: modulesDir: ["../layer/node_modules"], it magically started kind of working.

Currently facing the same issue. Thanks for the workaround. In my case I intend to create a npm package so is not that much on a issue. Did you open an issue?

I also had to add root node_modules folder: modulesDir: ["../layer/node_modules", "node_modules"] otherwise sass would break, don't ask me why tho.

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

7 participants