Node.js examples

983 views
Skip to first unread message

Tranek

unread,
Apr 27, 2013, 7:56:53 PM4/27/13
to pap...@googlegroups.com
How do I run the Node.js examples?

I installed paper.js as a node module (have to npm install canvas first which requires the Cairo libraries) using:


After getting it installed, I tried to run the examples using:

node AnimatedStar.js

and it errors with:

dan@ubuntu:~/Desktop/papertest/node_modules/paper/examples/Node.js$ node AnimatedStar.js 

/home/dan/Desktop/papertest/node_modules/paper/node.js/index.js:45
vm.runInContext(source, context, uri);
  ^
ReferenceError: self is not defined
    at ../../lib/acorn-min.js:1:24949
    at vm.createContext.include (/home/dan/Desktop/papertest/node_modules/paper/node.js/index.js:45:6)
    at core/PaperScript.js:19:7
    at vm.createContext.include (/home/dan/Desktop/papertest/node_modules/paper/node.js/index.js:45:6)
    at new <anonymous> (paper.js:125:7)
    at paper.js:32:13
    at Context.vm.createContext.include (/home/dan/Desktop/papertest/node_modules/paper/node.js/index.js:45:6)
    at Object.<anonymous> (/home/dan/Desktop/papertest/node_modules/paper/node.js/index.js:51:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)


This same error happens on both Ubuntu 13.04 (64-bit) and Windows 7 64-bit.

What am I doing wrong?

Thanks

Tranek

unread,
Apr 30, 2013, 3:25:31 PM4/30/13
to pap...@googlegroups.com
Adding the require('paper') line to any node app results in the error too.

I'm using nodejs 0.10.4 on both Windows 7 64-bit and Ubuntu 13.04 64-bit.

Thoughts? Is there any more information that I can provide to help figure out how to make it work?

Thanks!

Tranek

unread,
Apr 30, 2013, 11:54:25 PM4/30/13
to pap...@googlegroups.com
Solved it! In the acorn-min.js, I changed the only instance of "self" to "this". Is this a change that we can push to the paperjs repository? 

Jürg Lehni

unread,
May 1, 2013, 4:52:12 AM5/1/13
to pap...@googlegroups.com
Oh wow. Thanks for spotting!

Before changing acorn.js we should try updating to the latest version and see if that works.

It's late here, will do so tomorrow.

J
> --
> You received this message because you are subscribed to the Google Groups "Paper.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to paperjs+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Tranek

unread,
May 1, 2013, 2:54:26 PM5/1/13
to pap...@googlegroups.com
This guy solved it first - https://github.com/paperjs/paper.js/issues/205

I look forward to hearing your response about the new version of acorn.

Thanks!


On Saturday, April 27, 2013 7:56:53 PM UTC-4, Tranek wrote:

Jürg Lehni

unread,
May 8, 2013, 1:44:54 AM5/8/13
to pap...@googlegroups.com
I have fixed this issue now, and have published paper to npm:

https://npmjs.org/package/paper

Please let me know how it works for you!

Note that version numbers are out of whack, but we'll soon release a proper 1.0 for browsers and node, and from there onwards will finally have a proper release cycle :)

Cheers,

Jürg

Tranek

unread,
May 8, 2013, 5:36:53 AM5/8/13
to pap...@googlegroups.com
Thanks Jurg! It's working great so far! It's so much better not having to include the paperjs node module in our project and instead just include it as a dependency in our package.json :)


On Saturday, April 27, 2013 7:56:53 PM UTC-4, Tranek wrote:
Reply all
Reply to author
Forward
0 new messages