ModuleNotFound error in vscode-ide-purescript

Purescript Beginner here

I seem to be getting a ModuleNotFoundError when using vscode-ide-purescript.

How I got to the error

1. creating directory

mkdir purescript-trial
cd purescript-trial

2. initializing yarn and installing purescript, spago and purty

yarn init -y
yarn add -D purescript spago purty

3. Initializing Spago

yarn spago init

4. Building Purescript with Spago

yarn spago build

This command builds the project and creates the output directory.

5. Pasting the following into the local settings.json in the project .vscode folder


  "purescript.addSpagoSources": true,
  "purescript.addNpmPath": true, 
  "purescript.buildCommand": "yarn spago build --purs-args --json-errors"

6. opening vscode at project level and getting a build prompt despite already having built the project earlier.

Screenshot from 2020-07-05 16-36-50

7. After Pressing Build Project it successfully builds.

8. After saving the Main.purs file that was generated from yarn spago build I seem to be getting the weird that none of the imports were found.

Thanks in advance.

1 Like

That definitely looks like unexpected behavior. Thanks for the clear report.

The following suggestions should not be required, but if any of these end up working, that will give us more info on the root cause of this issue.

  • Ctrl+Shift+p, “Purescript: Restart / Reconnect purs IDE server”
  • Enable Purescript: Editor Mode in settings.
  • Try a global install of purescript and spago.
1 Like

Thanks for the reply. After a global install of spago, purescript and purty I can’t seem to get it working.

I am reading through the output of the ide in vscode.

Right now am just writing code and using the terminal to evaluate it. I really hope I find why it does not work.

I was able to solve the problem by uninstalling:

  1. vscode
  2. yarn

and then installing them using nix.`nix which worked for some reason.

I had installed vscode using snap and yarn using apt-get.

I still don’t know why it worked but am glad.

Thanks for your help.


I don’t know if this makes any difference, but I’ve seen the above idiom fail recently. In my config I have

spago build --purs-args="--json-errors"