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
{{ message }}
Repository navigation
safeRequire returning undefined even when module is installed #833
arc depends on loopback
arc depends on workspace
workspace depends on loopback
workspace depends on cookie-parser
Since the versions are compatible (I assume) npm installs only one loopback package in arc's node_modules directory (and nothing in workspace). This breaks the assumptions safeRequire() makes - which is that the loopback will be a dependency of the module that has the independent middleware installed (eg. serve-favicon, which is installed in workspace).
I'm not exactly sure how we can fix this with npm's behavior. Npm chooses to install only a single loopback module. Currently we just install the modules in arc. This is a bit unsettling because they are not arc's dependencies (they are workspace's).
I think the correct fix is to stop using loopback.{name} shortcuts and load the middleware directly via require. See strongloop/loopback-workspace#166 for an example of such change.
It would be even better to 1) upgrade loopback-workspace to use the new 2.x project layout 2) convert it to a proper loopback component, so that strong-arc can import workspace models into the main strong-arc app.
BTW I have run into the same problem when I was npm link-ing loopback to a different project. Node module lookup uses the real path (e.g. ~/src/loopback), not the symlink path (e.g. ~/src/loopback-boot/node_modules/loopback) and thus it look into ~/src/loopback-boot/node_modules when resolving require called from loopback.
We should use as much middleware as we can directly, and use loopback shortcuts only where necessary: loopback.static and loopback.favicon.
This should be fixed as of loopback-boot@2.7.0. Please upgrade your projects to use this new version and reopen this issue if the problem still persists.
Activity
bajtos commentedon Nov 19, 2014
I think the correct fix is to stop using
loopback.{name}shortcuts and load the middleware directly viarequire. See strongloop/loopback-workspace#166 for an example of such change.It would be even better to 1) upgrade loopback-workspace to use the new 2.x project layout 2) convert it to a proper loopback component, so that strong-arc can import workspace models into the main strong-arc app.
bajtos commentedon Nov 19, 2014
BTW I have run into the same problem when I was
npm link-ing loopback to a different project. Node module lookup uses the real path (e.g. ~/src/loopback), not the symlink path (e.g.~/src/loopback-boot/node_modules/loopback) and thus it look into~/src/loopback-boot/node_moduleswhen resolvingrequirecalled from loopback.We should use as much middleware as we can directly, and use loopback shortcuts only where necessary:
loopback.staticandloopback.favicon.bajtos commentedon Jan 16, 2015
I believe this issue is a duplicate of strongloop/loopback-boot#73
bajtos commentedon Apr 16, 2015
This should be fixed as of
loopback-boot@2.7.0. Please upgrade your projects to use this new version and reopen this issue if the problem still persists.