Javascript 需要使用coffeescript编写节点模块
我有两个文件,一个是控制器,另一个是此控制器的测试,都在coffeescript中,并且在同一文件夹中: 文件夹结构为:Javascript 需要使用coffeescript编写节点模块,javascript,node.js,coffeescript,Javascript,Node.js,Coffeescript,我有两个文件,一个是控制器,另一个是此控制器的测试,都在coffeescript中,并且在同一文件夹中: 文件夹结构为: -controller --labels.controller.coffee --labels.controller.spec.coffee 标签.控制器提取: module.exports = { getImages: getImages } 我正试图从labels.controller.spec中要求对其进行测试 我试过了 labelsContro
-controller
--labels.controller.coffee
--labels.controller.spec.coffee
标签.控制器
提取:
module.exports = {
getImages: getImages
}
我正试图从labels.controller.spec中要求对其进行测试
我试过了
labelsController = require('labels.controller')
及
及
但总有这样的错误:
Error: Cannot find module '../labels.controller'
我做错了什么?如果包含用coffeescript编写的文件,有什么区别吗?您需要先用
coffee
命令编译它。在项目源代码中,运行此命令(假设项目是用coffeescript编写的)
其中src
是您的项目文件夹。然后使用节点运行输出中的.js
文件
labelsController = require('/labels.controller')
Error: Cannot find module '../labels.controller'
coffee -co output/ src/