You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently access packages like this import { foo } from 'foo/bar';. It seems the current bootstrap only creates node_modules/foo/index.js with module.exports = require('/full/path/packages/foo');. Thus when accessing foo/bar, it Error: Cannot find module.
What would be the best path forward for supporting this? The only thing I can think of is to find all *.js paths and then create that path with matching exports.
Reacted by Cole Chamberlain, Zoltan Kochan, Hugh Kennedy, Kaelan Cooter, Dennis Torres, Yves M., Travis Kaufman, Zetta Flow, Mo Doaie and AlexandrAnash
I've hit this too, it's especially nasty when you're trying to test stuff that is trying to import a subpath generated by Babel (const foo = require('my-sibling-package/lib/foo');). An approach like npm-sync can work for simple use cases, but clearly doesn't scale for a lerna-based monorepo.
Symlinking is it's own ball of wax, since node's require() always calls realpath on the requested module path and thus it resolves the symlinks and now everything breaks because symlinks are. the. worst.
Maybe expand the createLinkedDepFiles method to loop over non-npmignored files and require those as well?
@evocateur I thought of the same as well and prototyped locally. One issue I ran into that you need a watcher when adding new files as they would need that shim to link the dependency files.
@thejameskyle I am not sure that npm is the issue here or what the goal would be? The module code is frozen in npm so introducing new behavior to load files locally isn't something they are going to accept (don't have the link ready to cite this but its in a discussion about linking local modules).
@patrickheeney I tried symlinking previously however npm install has weird behavior around installing recursively through symlinks which I don't think is intentional.
Sorry, just another me too message, but just to say that Lerna is unusable for my use-case at present without this feature.
If there are issues with sym-linking the directory, is it not possible to use the current approach of adding module.export = require() files, but for all files?
Reacted by Tim Finley, Zoltan Kochan, Hugh Kennedy and Dennis Torres
Is there a summary of what was actually implemented anywhere? I've read through this issue, the changes, and the docs, but I'm unclear what the net-net is.
My specific question is: in my root package.json I have a dependency foo. This dependency is also present as packages/foo. I would like the app to install whichever version of foo is currently present at packages/foo. Additionally, I'd like to be able to modify packages/foo and have the changes reflected in node_modules/foo.
Should I use a simple file: link, or is there something else that I should do?
I'm still experiencing issues symlinking when running lerna bootstrap. I have 2 packages, one depends on the other, both are under packages/, lerna boostrap reports that it has symlinked the two, but packages/a/node_modules/b is not a symlink to packages/b, so changes are not propagated.
I have the exact problem as @shimmerjs and @k3n,, i have to manually run lerna bootstrap to get the changes across, anything i am missing out on here ?
@aga5tya I fixed this by specifying the dependencies with explicit versions (instead of latest) and then lerna bootstrap realized they needed to be linked. Moving forward, publish will keep them in sync. This is confusing behavior granted npm itself no longer is this strict about linking, but definitely workable. Cheers.
@liuchong If you’re not publishing any packages, don’t use lerna. Relative imports are not bad.
That said, you can add ”private”: true to the package.json of any package you do not want lerna to publish. Ensure that the private package is not a runtime dependency of anything you do publish, or the dependents will be broken when consumed outside your monorepo.
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Activity
jamiebuilds commentedon Jan 28, 2016
@kittens any reason we don't just symlink everything?
jamiebuilds commentedon Feb 1, 2016
This should be fixed by #34, but be warned that we're not sure if this will cause other issues and we might revert it with another major bump.
jamiebuilds commentedon Feb 2, 2016
Symlinking causes other issues with npm, we'll have to figure something else out.
patrickheeney commentedon Feb 11, 2016
This seems to be outside the scope of the project, closing this.
jamiebuilds commentedon Feb 11, 2016
It's not, we need to figure it out in another way
evocateur commentedon Feb 23, 2016
I've hit this too, it's especially nasty when you're trying to test stuff that is trying to import a subpath generated by Babel (
const foo = require('my-sibling-package/lib/foo');). An approach like npm-sync can work for simple use cases, but clearly doesn't scale for alerna-based monorepo.Symlinking is it's own ball of wax, since node's
require()always callsrealpathon the requested module path and thus it resolves the symlinks and now everything breaks because symlinks are. the. worst.Maybe expand the
createLinkedDepFilesmethod to loop over non-npmignored files and require those as well?jamiebuilds commentedon Feb 23, 2016
I want to narrow down the issue in npm and see if it can be patched.
patrickheeney commentedon Feb 23, 2016
@evocateur I thought of the same as well and prototyped locally. One issue I ran into that you need a watcher when adding new files as they would need that shim to link the dependency files.
@thejameskyle I am not sure that npm is the issue here or what the goal would be? The module code is frozen in npm so introducing new behavior to load files locally isn't something they are going to accept (don't have the link ready to cite this but its in a discussion about linking local modules).
jamiebuilds commentedon Feb 24, 2016
@patrickheeney I tried symlinking previously however
npm installhas weird behavior around installing recursively through symlinks which I don't think is intentional.dchambers commentedon Feb 24, 2016
Sorry, just another me too message, but just to say that Lerna is unusable for my use-case at present without this feature.
If there are issues with sym-linking the directory, is it not possible to use the current approach of adding
module.export = require()files, but for all files?65 remaining items
k3n commentedon Feb 8, 2017
Is there a summary of what was actually implemented anywhere? I've read through this issue, the changes, and the docs, but I'm unclear what the net-net is.
My specific question is: in my root
package.jsonI have a dependencyfoo. This dependency is also present aspackages/foo. I would like the app to install whichever version offoois currently present atpackages/foo. Additionally, I'd like to be able to modifypackages/fooand have the changes reflected innode_modules/foo.Should I use a simple
file:link, or is there something else that I should do?Thanks in advance.
hzoo commentedon Feb 8, 2017
Uhh well one of the changes is that bootstrap uses symlinks + you can use the packages key to specify the folders that will be packages https://github.com/lerna/lerna#lernajson including root (
.)made #589
k3n commentedon Feb 9, 2017
Thank you, though I'm still battling through my problem.
k3n commentedon Feb 10, 2017
Ok, I think my issue is that I was trying to have a 'top-level' module. Once I made everything a package, it works as expected.
aeweidne commentedon May 17, 2017
I'm still experiencing issues symlinking when running
lerna bootstrap. I have 2 packages, one depends on the other, both are underpackages/,lerna boostrapreports that it has symlinked the two, butpackages/a/node_modules/bis not a symlink topackages/b, so changes are not propagated.aga5tya commentedon May 30, 2017
I have the exact problem as @shimmerjs and @k3n,, i have to manually run lerna bootstrap to get the changes across, anything i am missing out on here ?
aeweidne commentedon May 30, 2017
@aga5tya I fixed this by specifying the dependencies with explicit versions (instead of
latest) and thenlerna bootstraprealized they needed to be linked. Moving forward,publishwill keep them in sync. This is confusing behavior grantednpmitself no longer is this strict about linking, but definitely workable. Cheers.Nested directory support has landed in learn therefore we can drop zk…
Merge branch 'upgrade-lerna' into 'master'
liuchong commentedon Oct 15, 2017
I'm also want a feature which let me "require/install/link a package without publish"
evocateur commentedon Oct 15, 2017
@liuchong If you’re not publishing any packages, don’t use lerna. Relative imports are not bad.
That said, you can add
”private”: trueto the package.json of any package you do not want lerna to publish. Ensure that the private package is not a runtime dependency of anything you do publish, or the dependents will be broken when consumed outside your monorepo.lock commentedon Dec 28, 2018
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.