例によって purescript に続いてpurescriptの学習を始めたばかりですが、Chapter2の最後でgrunt project templates を使用して立ち往生しています。指示に従いますが、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
とnode index.js
、すべて正常に動作します。これを純粋なスクリプトで修正するためにできることがあるかどうか、それとも私が間違っていることであるかどうか疑問に思っていました。