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
fix node_modules problem #1
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that this would prevent users from running
npm install sails-mysql
to install the mysql adapter in their apps-- but maybe I'm missing something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, you can install whatever you wish and it will load just fine. What's the difference between:
require('package')
andrequire('./some/folder/node_modules/package')
.If
package
is installed on project root e.g../
,./some/folder/app.js
will go up and will find thepackage
so we're good.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stanislavromanov If I'm understanding you correctly, there's still a problem (at least with the versions of Node and NPM I've used in the past). If code in
sails-hook-orm
(a dependency ofsails
, which is a dependency of your project) attempts torequire('sails-mysql')
, then Node will look at the dependencies ofsails-hook-orm
-- in its node_modules folder. And like you're saying, it will continue to look at higher and higher level directories that have a package.json, attempting to find the dependency. But for some reason or another, this just doesn't work, at least not on all versions of Node/NPM that we support (I started off trying to do it that way, and only changed it after it didn't work for some developers. I had to do the same thing for generators, view engines, hooks, socket.io adapters, and connect session adapters.)All that said, it may be that this is fixed now on all versions of NPM/Node in common use today (i.e. Node >=0.10 and NPM >= 2.0). If that's the case, then we just need some more test cases that verify that this works (Travis can take care of testing on multiple versions of Node-- I'll make sure I push up a travis.yml file for this repo). I'd love to be able to simplify this code throughout the framework!