Error when using cram (Cannot find module, while it's there)

82 views
Skip to first unread message

Lars Kappert

unread,
Feb 26, 2013, 3:53:04 PM2/26/13
to cuj...@googlegroups.com
Hi,

The cram builder is giving me an issue. The command and the error message:

$ node src/lib-dev/cram/cram.js src/app-cujo/index.html -r src/app-cujo/ -o dist
info: Parsing src/app-cujo/index.html for curl configuration
info: Found data-curl-run: main
info: Including loader: ../lib-dev/curl/src/curl.js
cram failed:  Cannot find module 'src/app-cujo/../lib-dev/wire/wire'
Error: Cannot find module 'src/app-cujo/../lib-dev/wire/wire'
    at Function.Module._resolveFilename (module.js:338:15)
    [...]

The command is run from the root of the project.

Also see the the config at https://github.com/webpro/baseplate/blob/cujo-curl/src/app-cujo/main.js. You could clone/fork and try it, but you would need to manually put the dev branches (of cram/curl/wire) in the src/lib-dev folder.

Got any idea what I'm doing wrong here? Or maybe I've hit a bug? Thanks in advance.

unscriptable

unread,
Feb 26, 2013, 4:07:30 PM2/26/13
to cuj...@googlegroups.com

not sure what's happening atm. try either/both of these two things: 1) put a baseUrl config option in your main.js file, 2) run cram.js from a higher (or lower) directory

Lars Kappert

unread,
Feb 26, 2013, 4:49:21 PM2/26/13
to cuj...@googlegroups.com
Seems my reply at gg got lost… Going to rewrite only the last part.


When using am absolute path (e.g. /Users/lars/..../baseplate/src/app-cujo) things work.

$ node src/lib-dev/cram/cram.js src/app-cujo/index.html -o out.js --loader src/lib-dev/curl/dist/curl/curl.js 
info: Parsing src/app-cujo/index.html for curl configuration
info: Found data-curl-run: main
info: Including loader: ../lib-dev/curl/src/curl.js

Using that out.js as "data-curl-run", I get a "Uncaught SyntaxError: Unexpected token function" because of:

if
(!args || args.ex) {
def.reject(new Error(((args && args.ex) || 'define('curl', {/** @license MIT License (c) copyright B Cavalier & J Hann */

/**
* curl (cujo resource loader)
* An AMD-compliant javascript module and resource loader
*
* curl is part of the cujo.js family of libraries (http://cujojs.com/)
*
* Licensed under the MIT License at:
*
*/
(function (global) {
//"use strict"; don't restore this until the config routine is refactored
var
version = '0.7.3',


Looks like the curl loader gets inserted "async" (at unexpected/random location?)…

I'm giving up for today. Would be great if you could look into this. I'd be happy to assist, try a specific scenario, just let me know.

Two notes: 

1. in the help it says the --output option is for output folder (not file). 
2. in the "launch" docs of cram it says "define(function (['curl'], function (curl) {" in examples (should probably just be define(['curl'], function (curl) {)


Kind regards,
L.

Lars Kappert

unread,
Feb 27, 2013, 3:59:03 AM2/27/13
to cuj...@googlegroups.com
Apologies if my reply came out light-hearted (it was late and I lost my more extensive post). Just wanted to add that I also tried without providing a --loader:

$ node src/lib-dev/cram/cram.js src/app-cujo/index.html -o out.
js
info
: Parsing src/app-cujo/index.html for curl configuration
info
: Found data-curl-run: main
info
: Including loader: ../lib-dev/curl/src/curl.js
cram failed
:  ENOENT, open '../lib-dev/curl/src/curl.js'
Error: ENOENT, open '../lib-dev/curl/src/curl.js'


This is with the dev branch for when (otherwise it's missing when/poll). I tried things with either relative or absolute paths for --root as CLI option, or by defining "baseUrl" in the config.

Let me know if you need more information. Of course you could check out the repo at github (cujo-curl branch).

Perhaps you guys have a working example of building an app using the cujo stack? I could take a look at that as well.

unscriptable

unread,
Feb 27, 2013, 2:26:47 PM2/27/13
to cuj...@googlegroups.com
Hey Lars!

Even thought gg lost your post, I stil received the email.  Thanks for all of that info.  

Quickly: Thanks for trying all those permutations of baseUrl.  Getting AMD pathing and node.js pathing working together makes my head hurt.  I thought I had it, but obviously there are still issues.  I have several tiny test projects that work, so obviously I need to add some better tests.

I have never seen the output get mangled like that.  I have seen the loader get output later than the run module (aka main module), but I have never seen modules collide like that.  There must be a bug in the code that injects the loader.  cram can determine the need for a loader by inspecting the html file.  I suspect that this mangling bug happens when you also specify the --loader CLI option.  I'll look into this: https://github.com/cujojs/cram/issues/12

> 1. in the help it says the --output option is for output folder (not file). 
> 2. in the "launch" docs of cram it says "define(function (['curl'], function (curl) {" in examples (should probably just 

Thank you!  Fixing those asap.

-- John
Reply all
Reply to author
Forward
0 new messages