reason
reason copied to clipboard
Quickstart doesn't work if you use npx
I assumed that - like most globals nowadays - you could use bs-platform via npx
~/code $ npx -p bs-platform bsb -init reason-playground -theme basic-reason
Making directory reason-playground
Symlink bs-platform in /Users/gmauer/code/reason-playground
turns out you cannot
~/code $ cd reason-playground/
~/code/reason-playground $ npm s
npm ERR! search must be called with arguments
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/gmauer/.npm/_logs/2019-10-28T02_20_36_086Z-debug.log
~/code/reason-playground $ npm run start
> [email protected] start /Users/gmauer/code/reason-playground
> bsb -make-world -w
sh: bsb: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] start: `bsb -make-world -w`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/gmauer/.npm/_logs/2019-10-28T02_20_47_999Z-debug.log
Seems like it expects a global bs-platform
installed.
Might I recommend installing bs-platform
as part of dev-dependencies and then using that local install?
This would also allow have the benefit of allowing the app generator to control the version of bs-platform
all this stuff runs against.
did you run npm install
in the created directory after your npx
?
You have to do rm -r node_modules/
otherwise you have a broken symlink node_modules/bs-platform -> ~/.npm/_npx/nnnnnn/lib/node_modules/bs-platform
causing npm install
to fail.
So, what worked was:
npx -p bs-platform bsb -init reason-playground -theme basic-reason
cd reason-playground/
rm -r node_modules/
npm install
npm run start
The npx -p bs-platform bsb -init reason-playground -theme basic-reason
line is creating 4 files:
$ cat reason-playground/bsconfig.json
{
"name": "reason-playground",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
$ cat reason-playground/package.json
{
"name": "reason-playground",
"version": "0.1.0",
"scripts": {
"build": "bsb -make-world",
"start": "bsb -make-world -w",
"clean": "bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "",
"license": "MIT",
"devDependencies": {
"bs-platform": "^7.1.0"
}
}
$ cat reason-playground/README.md
...
$ cat reason-playground/src/Demo.re
Js.log("Hello, BuckleScript and Reason!");
Copying those files in another directory:
$ mkdir hello-bsb
$ cd hello-bsb/
$ cp ../reason-playground/bsconfig.json .
$ cp ../reason-playground/package.json .
$ mkdir src
$ cp ../reason-playground/src/Demo.re src/
is sufficient to have the same results with npm install
and npm run start
.
(The only prerequisite is sudo apt install nodejs
.)
bs-platform is the old package from BuckleScript, which is now called ReScript.
Using npx with ReScript shouldn't have any problem, otherwise open an issue on their repo: https://github.com/rescript-lang/rescript-compiler