I try to run this simple code in node.js:
var YUI = require("yui3");
YUI.use(function(Y) {
console.log('asdasd');
})
But I get the following error:
node.js:178
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'runInNewContext' of undefined
at Object.<anonymous> (/usr/local/lib/node/.npm/yui3/0.5.34/package/lib/yui3-yui3.js:7:29)
at Module._compile (module.js:404:26)
at Object..js (module.js:410:10)
at Module.load (module.js:336:31)
at Function._load (module.js:297:12)
at require (module.js:348:19)
at /usr/local/lib/node/.npm/yui3/0.5.34/package/lib/node-yui3.js:2:16
at Object.use (/usr/local/lib/node/.npm/yui3/0.5.34/package/lib/node-yui3.js:41:15)
at Object.<anonymous> (/var/www/myDir/libs/nodejs-yui3/yui3_test.js:6:5)
at Module._compile (module.js:404:26)
How can I fix this?
[Edit]
I'm using: node v0.5.0-pre
I'm unable to reproduce this. I followed these steps:
Installed YUI3:
[BinaryMuse ~/src]: npm install yui3
[ lots of output ... ]
npm info build Success: yui3@0.5.34
npm info build Success: request@1.9.5
npm info build Success: mime@1.2.1
npm info build Success: express@2.2.2
npm info build Success: connect@1.3.0
npm info build Success: qs@0.1.0
npm info build Success: htmlparser@1.7.3
npm info build Success: yui3-core@3.3.0
npm info build Success: jsdom@0.2.0
npm ok
Created the file yui.js
:
var YUI = require("yui3");
YUI.use(function(Y) {
console.log('asdasd');
});
Ran the program:
[BinaryMuse ~/src]: node yui.js
asdasd
I know this doesn't really "answer" your question, but perhaps knowing that it works will point you in the right direction. Good luck!
[Update] I'm on Node v0.4.5.