【发布时间】:2016-03-16 10:02:31
【问题描述】:
我在 Windows 8 上使用带有 Node.js 的 CoffeeScript。我有一个包含 2 个文件的目录,main.coffee 和 test.coffee。 main.coffee 中的代码是:
test = require "./test.coffee"
console.log test.x * 2
test.coffee 的代码是:
x = 2
当我运行coffee main.coffee -n 时,我会返回NaN。我尝试在 require 和 console.log 上使用括号,但它并没有改变任何东西。
【问题讨论】:
-
您需要从您的 test.coffee 文件中设置导出值。例如。
module.exports = { x: 2 }将是test.x //2
标签: node.js coffeescript require