canjs/can-compile

Dosent install with npm on Windows

cherifGsoul opened this issue · 26 comments

I just want to install it on Windows 7 and the command console shows errors :

> contextify@0.1.7 install C:\Users\b.cherif\AppData\Roaming\npm\node_modules\ca
n-compile\node_modules\jsdom\node_modules\contextify
> node-gyp rebuild


C:\Users\b.cherif\AppData\Roaming\npm\node_modules\can-compile\node_modules\jsdo
m\node_modules\contextify>node "C:\Program Files\nodejs\node_modules\npm\bin\nod
e-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod
e_modules\node-gyp\lib\configure.js:101:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\b.cherif\AppData\Roaming\npm\node_modules\can-compile\node
_modules\jsdom\node_modules\contextify
gyp ERR! node -v v0.10.24
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
npm ERR! contextify@0.1.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the contextify@0.1.7 install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "can-compile" "-g"
npm ERR! cwd E:\myapp
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     E:\myapp\npm-debug.log
npm ERR! not ok code 0

This is a known issue. Check out https://github.com/tmpvar/jsdom#contextify

Also, you may be interested in https://github.com/stevenvachon/can-boilerplate instead of generator-canjs

taai commented

I finally made it to install on my Windows 7. This is unpleasant, but it really requires this:

Windows

Node 0.12 will have a native version similar to contextify, so this issue will soon fade away.

I followed the 3 steps mentioned above and still no luck. Errors same as @cherifGsoul mentioned. Any thoughts?

This is probably still an issue with contextify. npm install contextify will probably fail, too but it might be easier to debug what's going wrong.

$ npm install contextify
npm http GET https://registry.npmjs.org/contextify
npm http 304 https://registry.npmjs.org/contextify
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/nan

contextify@0.1.8 install c:\Users\xxxxxxxx\local1\canjs\node_modules\contextify
node-gyp rebuild

c:\Users\xxxxxxxx\local1\canjs\node_modules\contextify>node "c:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild
The system cannot find the path specified.
gyp: Call to 'node -e "require('nan')"' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (c:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:340:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "c:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd c:\Users\xxxxxxxx\local1\canjs\node_modules\contextify
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok
npm ERR! contextify@0.1.8 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the contextify@0.1.8 install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "c:\Program Files (x86)\nodejs\node.exe" "c:\Program Files (x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "contextify"
npm ERR! cwd c:\Users\xxxxxxxx\local1\canjs
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.9
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! c:\Users\xxxxxxxx\local1\canjs\npm-debug.log
npm ERR! not ok code 0

@stevenvachon Mind explaining a little how vm.createContext([sandbox]) would work with this? Not making total sense to me.

@mwilloam it is a native version of contextify with no OS issues. When Node v0.12 is released, can-compile can be updated to use it instead, thereby resolving this issue. Until then, I guess use a Unix-based OS.

Alternatively, can.stache—as opposed to can.mustache—offers better performance and cannot [yet?] benefit from pre-compilation.

@stevenvachon thanks for the info. So it's a Node/os quirk. Pre-comp is important to us for more than just performance. We need views rendered to functions so they can live in our scripts on a cross-domain cdn which is an issue ajaxing for .mustache and .ejs files. Yes, CORS, but we have some other issues around that. Pre-compilation is ideal.

@mwilloam With can.stache, you can still concatenate all of your templates into your script file. The only difference is that they will remain strings and will not be compiled into functions. It shouldn't affect XSS.

@stevenvachon What's the automated process for this? BTW, I just realized stache is its own template type.

But say I have 10 mustache files, how are you suggesting getting them from there to strings in my compiled JS(s)? And how would stache reference them individually if initially they are pathed like can.stache('/js/views/someTpl.mustache', {}); ?

@mwilloam I think this would be features in the new, currently unlaunched (though, released) version of Steal Tools. I have yet not fiddled with can.stache, but from one of the Bitovi hangout meetings I viewed, it does or will do this. Probably stores each template in a variable within can.concatenatedTemplatesOrSomething. Referencing them would be no different, similarly to how can-compile interfaces with CanJS.

@stevenvachon Hmm ... so dead end for us right now. Also, we're utilizing require/grunt. Curious how that will work. Thanks again!

I actually started working on a RequireJS view loader that basically just loads the plain text templates. You won't get the benefit of pre-compiled views but it'll work with RequireJS out of the box. Also, did everyone check the contextify Windows installation guides at https://github.com/brianmcd/contextify/wiki/Windows-Installation-Guide?

I was able to get contextify to load by uninstalling 64 bit version of node and switching to 32 bit version.

hi, are there any news about can-compile?
i am not able to install contextify since cherifGsoul posted this issue.
i have tested can-steal. on easy applications i can build a production version of controllers and views. can-workshop didnt work...

is there any idea to replace can-compile with can-steal and is there any gulp task to do things in can-steal like in can-compile?

This is not really a can-compile issue and unless contextify can install on Windows there probably won't be a fix for this.

When using Steal you can however use steal-tools and latest CanJS from the minor branch to load and compile views without needing a DOM. can-compile will probably also use the DOM-less shims once it is released with CanJS 2.2.

How can I compile and combine more mustace or stache views with steal-tools? The documentation only shows how to build a production file.

As you said, can-compile not need the dependency contextify in version 2.2? So i can install can-Compile on windows without errors?

So it turned out that installing Python on Windows might solve the Contextify problem as well.

i have installed python 2.x and the problem is still unsolved....
there are a bunch of thread about the problem with contextify and windows. installing visual studio 2003 express might by a solution, but for me it is not (installing a programm with about 300 MB) für only one node packet

So... JSDOM 4.0 now works without contextify but only in io.js. Maybe a can-compile 1.0 is in order that uses JSDOM 4.0 and also works offline.

@daffl do you have any plans to remove contextify as a dependency for can-compile?
i installed oi.js but it seems that can-compile still uses contextify.
i want to compile my views like stache in a smaler production file

pilou commented

Any progress to pre-compile .mustache on windows 8.1 x64?
Workaround or something?

Should I use stache and require optimizer instead?

daffl commented

This should also be closed by using can-simple-dom via #45