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

[patch] Use node module resolution properly #4303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Swatinem
Copy link

@Swatinem Swatinem commented Feb 2, 2018

For quite a few cases, sails does not use the default node module resolution algorithm, but builds explicit paths in ${appPath}/node_modules/, which is not nice.

@sailsbot
Copy link

sailsbot commented Feb 2, 2018

Thanks for posting, @Swatinem! We'll look into this ASAP.


For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.

@mikermcneil
Copy link
Member

mikermcneil commented Mar 25, 2018

@Swatinem Why do you feel that this is not nice? (There's a reason we do it this way.)

@Swatinem
Copy link
Author

We have multiple sails apps inside a mono-repo, and would like to hoist some dependencies to the toplevel.
We worked around this problem anyway by just creating symlinks where needed.

@tomasfrancisco
Copy link

tomasfrancisco commented Apr 5, 2018

I might have the same problem.

I'm trying to set up a mono repo with yarn workspaces and I'm getting the following error when I try to run sails:

Failed to lift app: TypeError: Cannot read property 'readJson' of undefined
    at Object.module.exports.bootstrap (/Users/tomasfrancisco/Documents/dev/example-project/api/config/bootstrap.js:53:8)

@Swatinem Can I ask you what exactly did you do to fix it?

@Swatinem
Copy link
Author

Swatinem commented Apr 5, 2018

Well you can:

  • use the nohoist feature of recent yarn > 1.5 to exclude certain things from hoisting
  • manually create symlinks from /packages/$FOO/node_modules/$BAR -> /node_modules/$BAR

We went the symlink route because yarn still hoists your workspace packages themselves, and we needed those because some of them were sails hooks.

So you want to nohoist:

  • connect-redis
  • sails-mysql (or equivalent)
  • anything that is a sails hook. Sails basically enumerates every package in ./node_modules/… and looks at the package.json to figure out if its a hook or not (please correct me if I‘m wrong)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants