当我尝试跑步时。一个coffeescript测试我得到这个错误:
/Users/me/git/ibm-cos-sdk-js/test/credentials.spec.coffee:366
return creds = new AWS.TemporaryCredentials({
^
TypeError: AWS.TemporaryCredentials is not a constructor
at setupCreds (/Users/me/git/ibm-cos-sdk-js/test/credentials.spec.coffee:366:22)
at Suite.<anonymous> (/Users/me/git/ibm-cos-sdk-js/test/credentials.spec.coffee:399:7)
at Object.create (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Suite.<anonymous> (/Users/me/git/ibm-cos-sdk-js/test/credentials.spec.coffee:398:5)
at Object.create (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Object.<anonymous> (/Users/me/git/ibm-cos-sdk-js/test/credentials.spec.coffee:362:3)
at Object.<anonymous> (/Users/me/git/ibm-cos-sdk-js/test/credentials.spec.coffee:694:4)
at Module._compile (module.js:635:30)
at Object.loadFile (/Users/me/git/ibm-cos-sdk-js/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19)
at Module.load (/Users/me/git/ibm-cos-sdk-js/node_modules/coffee-script/lib/coffee-script/coffee-script.js:211:36)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at /Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/Users/me/git/ibm-cos-sdk-js/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm ERR! Test failed. See above for more details.
这里有一些我不确定的事情。首先,第366行不存在return creds = new AWS.TemporaryCredentials({
。我认为错误实际上是指第370行的creds = new AWS.TemporaryCredentials(DurationSeconds: 1200)
。我相信coffeescript会被转换为JavaScript。错误消息是否可能是生成的JavaScript的第366行?
另外,我不知道如何解决这个问题。任何建议将不胜感激。
答案 0 :(得分:0)
是的,错误消息是在javascript中给出的(正如您在Coffeescript中未使用的return
关键字所指出的那样),行号来自coffeescript的已转换的javascript版本文件。您可以使用sourcemaps获得更好的行号,但我不熟悉将它们与测试库一起使用。
在这种特定情况下,您正在运行npm包的测试。在Github上查找,缺少的构造函数实际上是not exist in the source code outside of tests。
该包看起来是AWS SDK的一个分支,并且仍在内部使用一些AWS方法。我的猜测是被删除的代码被删除了,但测试没有更新。尝试联系软件包维护人员或在Github上打开问题。