spago
spago copied to clipboard
"Getting Started": build-app gives "Failed to find esbuild"
Following the steps in the Getting Started guide gives the following output when reaching the section "Creating Executables":
$ spago build-app
[info] Build succeeded.
[error] Failed to find esbuild. See https://esbuild.github.io/getting-started/#install-esbuild for ways to install esbuild.
purs version 0.15.4 and spago 0.20.9, node 16.13.0 and npm 8.19.2, ubuntu 20 on x86.
Steps to reproduce:
mkdir my-project
cd my-project
spago init
spago install lists foldable-traversable
cat << EOF > src/Euler.purs
module Euler where
import Prelude
import Data.List (range, filter)
import Data.Foldable (sum)
ns = range 0 999
multiples = filter (\n -> mod n 3 == 0 || mod n 5 == 0) ns
answer = sum multiples
EOF
cat << EOF > src/Main.purs
module Main where
import Prelude
import Euler (answer)
import Effect.Console (log)
main = do
log ("The answer is " <> show answer)
EOF
spago build
spago bundle-app
Seems like esbuild needs to be installed globally. the following worked for me:
npm install -g esbuild
But isn't it quite common to have it installed locally? Would it maybe make sense to have a flag used like --es-build-command 'yarn run esbuild'?
This is a defect in the "Getting Started" guide that should be fixed. Web development newbies like I am just trying out to learn PureScript can't figure out how to fix this. I have tried npm install esbuild (after running npm init in the same directory where I ran spago init) but spago bundle-app still gives the same error. I refuse installing esbuild globally until I get more clarity on this.
I agree, esbuild shouldn't be installed globally. As a work-around, if you use npm run spago bundle-app with npx, ie npx spago bundle-app. This finds a local installation of esbuild. For other package managers, use the equivalent of npx.