Skip to content
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

Error thrown on build with 0.1.3 #56

Closed
patlecat opened this issue May 6, 2013 · 23 comments
Closed

Error thrown on build with 0.1.3 #56

patlecat opened this issue May 6, 2013 · 23 comments

Comments

@patlecat
Copy link

patlecat commented May 6, 2013

I got this persistent error on Windows8-64 with node.js v0.10.5 and ember-tools 0.1.3. And I just followed the simple example on your site here.:

C:\xxx\AppData\Roaming\npm\node_modules\ember-tools\src\commands\build.js:62
if (error) throw new Error(error);
^
Error: Error: Command failed: 'C:\xxx\AppData\Roaming\npm\node_modules\ember-tools\src\commands/../
../node_modules/browserbuild/bin/browserbuild' is not recognized as an internal or external command,
operable program or batch file.

at C:\xxx\AppData\Roaming\npm\node_modules\ember-tools\src\commands\build.js:62:22
at ChildProcess.exithandler (child_process.js:636:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:730:16)
at Socket.<anonymous> (child_process.js:943:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:451:12)
@fivetanley
Copy link
Collaborator

Bah, Windows paths strikes again! Thanks, I'll try to find time to fix this one.

@patlecat
Copy link
Author

I'd love to test it, I want to use ember for my new project. When do you think the fix will be ready?

@ryanflorence
Copy link
Owner

Can you try building with browserbuild directly? https://github.com/LearnBoost/browserbuild

@patlecat
Copy link
Author

patlecat commented Jun 2, 2013

The build still doesn't work in the actual version 0.2 :(

C:...\my-app>ember build
created: js/templates.js
created: js/index.js
created: js/application.js
'C:...\AppData\Roaming\npm\node_modules\ember-tools\src\commands/../../node_modules/browserbuild/
bin/browserbuild' is not recognized as an internal or external command,
operable program or batch file.

C:...\AppData\Roaming\npm\node_modules\ember-tools\src\commands\build.js:66
if (error) throw new Error(error);
^
Error: Error: Command failed: 'C:...\AppData\Roaming\npm\node_modules\ember-tools\src\commands/../
../node_modules/browserbuild/bin/browserbuild' is not recognized as an internal or external command,
operable program or batch file.
at C:...\AppData\Roaming\npm\node_modules\ember-tools\src\commands\build.js:66:22
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)

@patlecat
Copy link
Author

patlecat commented Jun 2, 2013

Can you try building with browserbuild directly?
How? I never used this.

@ryanflorence
Copy link
Owner

Just follow the directions on the README

@patlecat
Copy link
Author

patlecat commented Jun 2, 2013

Give me the string to execute please. I don't know your lib nor that browserbuild. But you know them.

@ryanflorence
Copy link
Owner

I'm saying just follow the demo on browserbuild's project site and see if it works in windows or not.

@patlecat
Copy link
Author

patlecat commented Jun 3, 2013

The result is the following code, which does not display "Hello world" in the browser though:

(function(){var global = this;function debug(){return debug};function require(p, parent){ var path = require.resolve(p) , mod = require.modules[path]; if (!mod) throw new Error('failed to require "' + p + '" from ' + parent); if (!mod.exports) { mod.exports = {}; mod.call(mod.exports, mod, mod.exports, require.relative(path), global); } return mod.exports;}require.modules = {};require.resolve = function(path){ var orig = path , reg = path + '.js' , index = path + '/index.js'; return require.modules[reg] && reg || require.modules[index] && index || orig;};require.register = function(path, fn){ require.modules[path] = fn;};require.relative = function(parent) { return function(p){ if ('debug' == p) return debug; if ('.' != p.charAt(0)) return require(p); var path = parent.split('/') , segs = p.split('/'); path.pop(); for (var i = 0; i < segs.length; i++) { var seg = segs[i]; if ('..' == seg) path.pop(); else if ('.' != seg) path.push(seg); } return require(path.join('/'), parent); };};require.register("lib\hithere.js", function(module, exports, require, global){
var b = require('./b')

module.exports = function () {
alert('hello ' + b());
}
});var exp = require('hithere');if ("undefined" != typeof module) module.exports = exp;else hithere = exp;
})();

@ryanflorence
Copy link
Owner

looks like it works then (just type hithere() in your terminal and it'll output the text).

So, something is up with the relative path, a fix might be to pull browserbuild in as a module and build with the module's api instead of as a binary (maybe?)

@patlecat
Copy link
Author

patlecat commented Jun 3, 2013

No it doesn't output anything, neither in the console of the browser nor in the HTML code below (path is correct):

<script src="my-library.js"></script> <script> hithere(); </script>

@Steve-OH
Copy link

I'm having the same problem (Win 7 x64), and I can see where stuff is going wrong, although I don't fully understand the intent, so I don't know why it's going wrong.

  1. Browserbuild does NOT work properly from a Windows cmd.exe command prompt (there's a command line parse error of some kind), but it does work from a bash prompt; I can build the example just fine.

  2. However, build.js sends the following command line to the command processor:

C:\Users...\node_modules/browserbuild/bin/browserbuild ...

The problem is that the command processor is trying to execute that file directly, which it can't do because it's a JavaScript file with no file extension. Rather than

.../bin/browserbuild

shouldn't the command line be

node .../bin/browserbuild

In any case, I made that modification, but it still didn't work. The full path now looks like this:

node C:\Users...\node_modules\ember-tools\src\commands/../../node_modules/browserbuild/bin/browserbuild -m index -g App -b js/ find -L js -name '*.js' > js/application.js

But this fails (again, under bash) with the following error:

find: invalid predicate `-L'

Which doesn't really make any sense to me...

-Steve

@ryanflorence
Copy link
Owner

Thanks @Steve-OH

Yeah, I'm relying on find, a bash program to load in all the files. -L tells it to follow symlinks.

Looks like we may need to branch on OS and use some cmd.exe thing to find the files we hand to browserbuild. I'd love for this to work for windows users, but I'm going to leave it to windows users to provide the pull request. I have no grudge against the OS, I'd just rather spend time on other things.

(sounds so mean)

@thomasvm
Copy link
Contributor

The above two changes make it the process run on my windows box. Instead of using find I'm using the glob node library to collect the js files and I explicitely use the node command to launch browserbuild. Warning: I have not tested this on a unix-box. If this would be good to go and you want me to create a separate pull request, just let me know.

@Steve-OH
Copy link

Those two changes seem to do the trick. Thanks.

-Steve

@Steve-OH
Copy link

Ryan,

I'd be happy to do a pull request, but the two changes really "belong" to Thomas.

Also, I don't have a way to test it on any *nix systems at the moment.

-Steve

@thomasvm
Copy link
Contributor

Pull request created as #65

@ryanflorence
Copy link
Owner

Fixed by 2a93006 and e345e29.

Thanks @thomasvm :D

@ryanflorence
Copy link
Owner

this fix was released to npm, so enjoy windows users 👯

@patlecat
Copy link
Author

Thanks guys, build now works on Windows :D

Just one small error in the Readme:
"open js/index.html" is incorrect because you place the index.html directly into my-app/ !

@Steve-OH
Copy link

You say "windows users" like it's a bad thing. ;-)

@thomasvm
Copy link
Contributor

Glad to see I made some "Micro$oft Windoze" users happy :-)

@Inframatic
Copy link

I'm having the same problem but on a Mac :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants