runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 127 forks source link

Cannot resolve module? #92

Closed facekapow closed 8 years ago

facekapow commented 8 years ago

I tried out the new version of runtime with runtime-shell and it just crapped out (runtime-shell, I mean) under the previous version, it worked fine. The exact error is:

Error: Cannot resolve module './lib/ping.js' from '/index.js'
  at Module.require (__loader:45:20)
  at /node_modules/runtime-shell/index.js:52:40
  at module.exports (/node_modules/runtime-shell/index.js:33:5)
  at /index.js:4:38
  at /index.js:7:3
  at Module.require (__loader:73:9)
  at Loader.require (__loader:235:25)
  at __loader:257:10
  at __loader

_But_, when I changed the './lib/ping.js' to __dirname + '/lib/ping.js', it worked perfectly. I ran through the code and console.loged every part that seemed it had something to with the path resolving and logs what it should until it gets to the resolvePath function, at which point resolveFrom becomes empty but before the function was called it was what it should be ('/node_modules/runtime-shell'). Any ideas why this is happening?

iefserge commented 8 years ago

@facekapow yep, this is a bug in the module loader. I'll fix soon. Thank you!

iefserge commented 8 years ago

@facekapow require issue is fixed, you may still get errors though because most Node.js builtin modules aren't supported yet https://github.com/runtimejs/runtime/pull/91

facekapow commented 8 years ago

I know, this isn't that though. I was trying to load my runtime-shell module which has no external dependencies, it just failed when requiring ping.js from lib. Thanks for the fix!