纯脚本 0.12 入门

Purescript 0.12 Getting Started

我正在尝试 运行 最基本的流程:

1) 安装工具:

npm install -g pulp bower

Pulp 版本 12.2.0 pur 版本 0.12.0 使用 C:\Users\panda.psvm\current\bin\purs.EXE C:\Users\panda>bower --version 1.8.4

2) 按照这个答案的步骤,我安装了 purs

C:\Users\panda>purs --version 0.12.0

好的,让我们创建一个项目。

c:\home\projects\sandbox\purr>mkdir hello-purr

c:\home\projects\sandbox\purr>cd hello-purr

c:\home\projects\sandbox\purr\hello-purr> pulp init

c:\home\projects\sandbox\purr\hello-purr>pulp init
* Generating project skeleton in c:\home\projects\sandbox\purr\hello-purr
bower purescript-console#*      cached https://github.com/purescript/purescript-console.git#4.1.0
bower purescript-console#*    validate 4.1.0 against https://github.com/purescript/purescript-console.git#*
bower purescript-prelude#*      cached https://github.com/purescript/purescript-prelude.git#4.0.0
bower purescript-prelude#*    validate 4.0.0 against https://github.com/purescript/purescript-prelude.git#*
bower purescript-prelude#^4.0.0 cached https://github.com/purescript/purescript-prelude.git#4.0.0
bower purescript-prelude#^4.0.0         validate 4.0.0 against https://github.com/purescript/purescript-prelude.git#^4.0.0
bower purescript-effect#^2.0.0            cached https://github.com/purescript/purescript-effect.git#2.0.0
bower purescript-effect#^2.0.0          validate 2.0.0 against https://github.com/purescript/purescript-effect.git#^2.0.0
bower purescript-console#^4.1.0          install purescript-console#4.1.0
bower purescript-prelude#^4.0.0          install purescript-prelude#4.0.0
bower purescript-effect#^2.0.0           install purescript-effect#2.0.0

purescript-console#4.1.0 bower_components\purescript-console
├── purescript-effect#2.0.0
└── purescript-prelude#4.0.0

purescript-prelude#4.0.0 bower_components\purescript-prelude

purescript-effect#2.0.0 bower_components\purescript-effect
└── purescript-prelude#4.0.0
bower purescript-psci-support#* cached https://github.com/purescript/purescript-psci-support.git#4.0.0
bower purescript-psci-support#*         validate 4.0.0 against https://github.com/purescript/purescript-psci-support.git#*
bower purescript-psci-support#^4.0.0     install purescript-psci-support#4.0.0

purescript-psci-support#4.0.0 bower_components\purescript-psci-support
├── purescript-console#4.1.0
├── purescript-effect#2.0.0
└── purescript-prelude#4.0.0

成功生成项目骨架。

正在尝试 运行 它:

pulp run

* Building project in c:\home\projects\sandbox\purr\hello-purr
Error 1 of 2:

  in module Main
  at src\Main.purs line 4, column 1 - line 4, column 31

    Module Control.Monad.Eff was not found.
    Make sure the source file exists, and that it has been provided as an input to the compiler.


  See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
  or to contribute content related to this error.

Error 2 of 2:

  in module Main
  at src\Main.purs line 5, column 1 - line 5, column 48

    Module Control.Monad.Eff.Console was not found.
    Make sure the source file exists, and that it has been provided as an input to the compiler.


  See https://github.com/purescript/documentation/blob/master/errors/ModuleNotFound.md for more information,
  or to contribute content related to this error.


* ERROR: Subcommand terminated with exit code 1

运气不好:(

pulp test
pulp build

相同的错误 - 找不到模块。 我错过了什么?请指教。 谢谢

找到解决方案。

  1. 根本不需要凉亭
  2. 相反,有一个 psc-package(另一个包管理器)
  3. 它没有在我的 Windows 10 和 npm install -g psc-package
  4. 上正确安装

目录 ${username}\AppData\Roaming\npm\node_modules\psc-package\vendor 中没有 psc-package.exe 文件 因此,您需要修复 install.js 文件并替换

ignore: ['psc-package']

ignore: [bin.use()]

然后 运行 使用

修复安装
${username}\AppData\Roaming\npm\node_modules\psc-package\lib> node install

之后,在 vendor 文件夹中,您可能会找到 psc-package.exe

然后,我按照本教程进行操作: https://github.com/justinwoo/purescript-0.12.0-hello-world

Build successful.
look, show on Record:
{ apple: "banana" }

Purescript 0.12 引入了较新版本的 Effect 和 Console 库,遗憾的是 pulp init 尚未更新以更正生成的示例以匹配(参见 https://github.com/purescript-contrib/pulp/issues/337

只需将 Main.purs 中的代码更新为:

module Main where

import Prelude (Unit)
import Effect
import Effect.Console (log)

main :: Effect Unit
main = do
  log "Hello sailor!"`

开始。