canjs/can-compile

TypeError: Cannot read property 'view' of undefined

Closed this issue · 6 comments

Can't figure out why this is happening:

$ npm --version
1.3.24

$ nodejs --version
v0.10.25

$ npm install can-compile
[...]

$ ./node_modules/.bin/can-compile --version
0.5.0

$ touch test.ejs

$ ./node_modules/.bin/can-compile test.ejs
Compiling test.ejs

/home/aljosa/tmp/tmp1/node_modules/can-compile/lib/compile.js:55
var id = can.view.toId(normalizer(filename));
^
TypeError: Cannot read property 'view' of undefined
at /home/aljosa/tmp/tmp1/node_modules/can-compile/lib/compile.js:55:17
at /home/aljosa/tmp/tmp1/node_modules/can-compile/lib/compile.js:20:9
at /home/aljosa/tmp/tmp1/node_modules/can-compile/node_modules/jsdom/lib/jsdom.js:207:39
at process._tickCallback (node.js:415:13)

What version of CanJS (if not specificed it will be the latest which is 2.0.5) and operating system are you using?

canjs 2.0.2 on linux

$ uname -a
Linux fakanana 3.11.0-15-generic #25-Ubuntu SMP Thu Jan 30 17:22:01 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=13.10
DISTRIB_CODENAME=saucy
DISTRIB_DESCRIPTION="Ubuntu 13.10"

head -n 9 ./apps/ui/static/v2/can.all-2.0.2.js
/*!

CanJS - 2.0.2
http://canjs.us/
Copyright (c) 2013 Bitovi
Sat, 16 Nov 2013 16:15:53 GMT
Licensed MIT
Includes: can/component/component.js,can/construct/construct.js,can/observe/observe.js,can/compute/compute.js,can/model/model.js,can/view/view.js,can/control/control.js,can/route/route.js,can/control/route/route.js,can/view/mustache/mustache.js,can/view/ejs/ejs.js,can/route/pushstate/pushstate.js,can/model/queue/queue.js,can/construct/super/super.js,can/construct/proxy/proxy.js,can/map/delegate/delegate.js,can/map/setter/setter.js,can/map/attributes/attributes.js,can/map/validations/validations.js,can/map/backup/backup.js,can/map/list/list.js,can/map/sort/sort.js,can/control/plugin/plugin.js,can/view/modifiers/modifiers.js,can/util/object/object.js,can/util/fixture/fixture.js
Download from: http://bitbuilder.herokuapp.com/can.custom.js?configuration=jquery&minify=true&plugins=can%2Fcomponent%2Fcomponent.js&plugins=can%2Fconstruct%2Fconstruct.js&plugins=can%2Fobserve%2Fobserve.js&plugins=can%2Fcompute%2Fcompute.js&plugins=can%2Fmodel%2Fmodel.js&plugins=can%2Fview%2Fview.js&plugins=can%2Fcontrol%2Fcontrol.js&plugins=can%2Froute%2Froute.js&plugins=can%2Fcontrol%2Froute%2Froute.js&plugins=can%2Fview%2Fmustache%2Fmustache.js&plugins=can%2Fview%2Fejs%2Fejs.js&plugins=can%2Froute%2Fpushstate%2Fpushstate.js&plugins=can%2Fmodel%2Fqueue%2Fqueue.js&plugins=can%2Fconstruct%2Fsuper%2Fsuper.js&plugins=can%2Fconstruct%2Fproxy%2Fproxy.js&plugins=can%2Fmap%2Fdelegate%2Fdelegate.js&plugins=can%2Fmap%2Fsetter%2Fsetter.js&plugins=can%2Fmap%2Fattributes%2Fattributes.js&plugins=can%2Fmap%2Fvalidations%2Fvalidations.js&plugins=can%2Fmap%2Fbackup%2Fbackup.js&plugins=can%2Fmap%2Flist%2Flist.js&plugins=can%2Fmap%2Fsort%2Fsort.js&plugins=can%2Fcontrol%2Fplugin%2Fplugin.js&plugins=can%2Fview%2Fmodifiers%2Fmodifiers.js&plugins=can%2Futil%2Fobject%2Fobject.js&plugins=can%2Futil%2Ffixture%2Ffixture.js */

@daffl even if i don't use "--can" to set canjs version and i repeat steps from first comment error is the same

Can you try to npm cache clean and also try installing it globally with npm install can-compile -g? I had a similar problem last week but it started working again after a while. Almost looked like an NPM hickup. Also, view files can't be empty.

@daffl don't know why but it just started working again

I know. Ran into a similar problem on the CI server. I'm assuming some kind of NPM hickup. I couldn't find anything wrong anywhere else.