YUI3 + node.js = runInNewContext 错误
我尝试在 node.js 中运行这个简单的代码:
var YUI = require("yui3");
YUI.use(function(Y) {
console.log('asdasd');
})
但我收到以下错误:
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)
我该如何解决这个问题?
[编辑]
我正在使用:节点 v0.5.0-pre
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我无法重现这个。我按照以下步骤操作:
安装了 YUI3:
创建了文件
yui.js
:运行程序:
我知道这并不能真正“回答”您的问题,但也许知道它有效会为您指明正确的方向。祝你好运!
[更新] 我使用的是 Node v0.4.5。
I'm unable to reproduce this. I followed these steps:
Installed YUI3:
Created the file
yui.js
:Ran the program:
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.
此错误是在 Node.js 0.5.0-pre 中引入的,请参阅问题 203 中的讨论。
要解决此问题,您可以:
This error introduced in Node.js 0.5.0-pre, see discussion in issue 203.
To fix this you can: