2

我刚刚开始通过示例学习 purescript,但我被困在第 2 章的末尾,使用 grunt 项目模板。我按照说明进行操作,但是当我运行 grunt 命令时出现此错误:

/Users/chad/playground/purescript/tests/tmp/node_modules/Control.Monad.Eff.Random/index.js:8
return Math.random();
            ^
TypeError: undefined is not a function
    at Object.random (/Users/chad/playground/purescript/tests/tmp/node_modules/Control.Monad.Eff.Random/index.js:8:17)
    at __do (/Users/chad/playground/purescript/tests/tmp/node_modules/Test.QuickCheck/index.js:177:52)
    at Object.__do (/Users/chad/playground/purescript/tests/tmp/node_modules/Main/index.js:19:201)
    at Object.<anonymous> (/Users/chad/playground/purescript/tests/tmp/index.js:1:79)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
Warning: -> error 1 /Users/chad/playground/purescript/tests/tmp/index.js (125ms) Use --force to continue.

Aborted due to warnings.

我通过深入研究代码发现的是模块 Math 被导入/output/Control.Monad.Eff.Random/index.js

var Math = require("Math");

function random() {
    return Math.random();
}
;

如果我删除导入,让 Math 成为本机并index.js简单地运行 main node index.js,一切正常。我想知道我是否可以在 purescript 中解决这个问题,或者我做错了什么。

4

1 回答 1

5

purescript-randompsc-make. _ 它将在下一个版本 0.6.7 中由编译器补丁修复,希望在本周。

作为一种解决方法,您应该能够purescript-randombower.json文件中或在命令行中指定以前的版本:

bower install purescript-random#0.1.1
于 2015-02-12T04:39:05.280 回答