Closed andreasgrimm closed 10 years ago
I've seen something like this happen when an exception is thrown in a module during it's initialization. (place a debugger at the top of your boot
component to see if that is the case)
I imagine that exceptions thrown like that should be caught, but if someone else has the same problem that I saw I would look into it a little deeper.
I debbuged boot/index.js and the regarding modules (e.g. base-page) are already undefined at this stage.
I should mention that I'm currently running the build on a windows machine. maybe paths get messed up in this case (due to back-slashes insted of forward-slashes)?
(edit) in a few hours I'm back on a Mac and can check if it's still a problem there.
That's certainly possible, I haven't used windows in a long time, and certainly never for component dev. :S
In the resulting build.js it's the line
require.register("./app\lib\base-page",
that messes up the module name.
and the line
require.modules["base-page"] = require.modules["./app\\lib\\base-page"];
that leads to the undefined state.
I wonder why in the register part the back-slashes won't get escaped opposed to the assignment statement where it seems correct .. but still is mixing up forward and backslashes
Would you say that's an issue belonging to the component/builder.js issues?
fyi: On a Mac it works. There the two lines are consistent and look like they should:
require.register("./app/lib/base-page",
and
require.modules["base-page"] = require.modules["./app/lib/base-page"];
As a result the objets' names in the require.modules array are correct, too.
Now do you think I should open an issue over at component/builder.js ? Is Windows OS officially supported in the first place? If not, on windows I could work around this error with a vagrant box. But it seems like much additional work for bootstraping ones component dev environment initially. At least if you wouldn't have virtual box / vagrant installed anyway.
(edit) oops, I think I was wrong and bundler.js would actually be the wrong place
my current workaround: in component.json set paths to "." and place all local component's folders in the root folder.
I fixed potential(?) bugs in component/builder2.js and component/build.js now it works just fine on windows machines .. although the resulting canonical names are not consistent compared to building it on a non-windows machine (because of the backslashes instead of the forwardslashes for paths)
Should I make Pull Requests and you want to take a look at it that way? .. or should we first discuss it here?
@andreasgrimm, I think this is the same issue (component/resolver.js#17) I had and which led back to component/resolver.js
. It's been fixed in version 1.1.4
but it's not yet sync'd with npmjs
registry...
Could you try referencing 1.1.4
directly in your package.json
(for now) to confirm that it fixes your issue? e.g.: dependencies: {"component-resolver": "component/resolver.js#1.1.4"}
I'm not sure about my permissions for publishing to npmjs.org
, @dominicbarnes, @jonathanong? ...
@clintwood I didn't stumble upon your fix in resolver.js at the time I did a search regarding this error. but that fix is actually more accurate, as it also addresses the inconsistency between windows and other systems I described and that'd be still existing with my fix. your fix seems to address the root of the problem. I don't see why your fix wouldn't work on my side. I can tell for sure in an hour or so whem I'm back at a windows machine.
on the other hand .. as the JSON.stringify is used inconsistently (which led to being a serious bug in the first place), maybe applying my fix would make it more consistent? ... or removing the other usages of it, if it isn't necessary
component/resolver.js#17 was the root cause in my case... personally I like to require
local components like so require('./path/to/component')
... It would be great if node.js only used the /
separator and did the translation under the covers... but meh!
@clintwood In what package.json files do I have to change the dependencies? I cloned component/component, changed it in it's package.json and installed the local module with -g. but that breaks it when calling component build
, resulting in Error: Cannot find module './build'
maybe I'm doing something wrong. though several component
dependendies on the other hand, in their package.json depend on component-resolver
as well, specifying a version different to 1.1.4
Any hint on addressing this circumstance?
@andreasgrimm, No you not doing anything wrong and yes in the component/component/package.json
, but the problem is that component-resolver
on npmjs.org
is also published with a build
folder with output from regenerator
. This is what is causing your error in your custom install.
As a hacky workaround to get you going (on Windows) until component/resolver.js
gets republished (see above) you can use "component-resolver": "clintwood/resolver.js#hack"
in component/component/package.json
in your cloned component/component
repo as before the do npm install -g .
from the cloned repo.
This should be resolved now, see component/resolver.js#20.
it is solved for me. thank you.
this error occurs in the browser and is reproducable with kewah/component-example that is linked here: https://github.com/component/guide/blob/master/component/examples.md
I'm new to component(1) and I didn't manage to get my head around what it is I'm doing wrong wanting to flex local components. So finally I tried to build and run kewah's example to which you're linking to in the component guide .. and "luckily" I was getting the same error.
I debugged it down to:
module "boot" is undefined. "about" and "base-page" are undefined as well. whereas "apppageshome" and the like are working. I tested in my own example when I require("apppageshome") then it works.
btw: see the missing characters "b" in the object names of the require.modules array? "appoot" should be "appboot", "applibase" should be "applibbase".
any clue what that could possibly cause this error?