Package size and error on Mac with global install


I just tried the basic Hello World examples and I noticed:

  • The “installation” section suggests to install the platform globally.
  • The scaffolded project has the platform as a local dependency.

I see that the “bs-platform” folder takes up 1GB of space. So here I just “lost” 2GB of my hard drive.

I understand that the package may be large, but it’s pretty wasteful on space having several projects with local install.

PS. Just tried to uninstall the local package and run “build”. Got an error (I am on Mac):

~/Projects/ReasonML/rescript-try(branch:master*) » npm run build

> new-project@0.0.1 build /Users/me/Projects/ReasonML/rescript-try
> bsb -make-world

[1/3] Building src/Demo.resast
FAILED: src/Demo.resast 
/Users/me/Projects/ReasonML/rescript-try/node_modules/bs-platform/darwin/bsc.exe  -warn-error +101  -o src/Demo.resast -bs-syntax-only -bs-binary-ast /Users/me/Projects/ReasonML/rescript-try/src/Demo.res
/bin/sh: /Users/me/Projects/ReasonML/rescript-try/node_modules/bs-platform/darwin/bsc.exe: No such file or directory
FAILED: subcommand failed.
npm ERR! errno 2
npm ERR! new-project@0.0.1 build: `bsb -make-world`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the new-project@0.0.1 build 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/me/.npm/_logs/2020-08-22T17_57_46_386Z-debug.log

Hey :slight_smile:

I see that the “bs-platform” folder takes up 1GB of space. So here I just “lost” 2GB of my hard drive.

Thats a little weird. Mine “just” takes up 150MB. I have no clue, why yours would be so much bigger.

PS. Just tried to uninstall the local package and run “build”. Got an error (I am on Mac):

If you run npm run clean (defined in package.json as bsb -clean-world), you will get a more helpful error message, stating the following:

Error: package bs-platform is not found 
It's the basic, required package. If you have it installed globally,
Please run `npm link bs-platform` to make it available

Hope it helps :slight_smile:

@eWert-Online, thank you for the quick response.

I did npm run clean, then got an error with a guideline to run npm link bs-platform. Now the build works ok.

As for the package size: maybe it’s the fact I am running on macOs High Sierra 10.13.6?

I see that there are several folders inside the folder package, among them:

/darwin - 25 MB
/lib - 124.4 MB
/linux - 37.4 MB
/native - 307.8 MB
/ocaml - 476.1 MB
/win32 - 34.7 MB

Looks like native and ocaml are the ones taking that space.

Also why are there linux, freebsd and win32 folders if I install the package on Mac?

The way I understand it: These are prebuilt binaries of rescript. Each Platform needs its own binary.
They are all published in the same npm package for convenience. Otherwise (or in case you’re using a platform which has no prebuilt binary) you would need to have the necessary toolchain installed and rescript would be built from scratch.

The reason why it’s also a local dependency: rescript also ships with js files which are needed during runtime.

I heard recent recommendations to install rescript only locally: If you have several projects using different rescript versions, having the dependency locally makes it more reproducable.
To use the init functionallity you could just use npx.
I think there was already an issue reported to make rescript compatible with yarn2, pnpm and the like.

^ Wait no, that’s not normal at all. Our install size is never that big. @mickeyvip could you file an issue to rescript-lang/rescript-compiler please?

The global install is for convenience tools, like some convenience formatting. The local install is for actual project usage (proper versioning, etc.)

Which scaffold are you checking out? Make sure you follow the official guidelines:

It seems that you on running on a old mac os version so that the prebuilt binary does not work for you, then it triggers we build ocaml compiler which consumes lots of space

Hi, disk usage is an issue for npm projects in general. You may want to try pnpm to save on disk space.

pnpm is not on our supported path so I’d caution against diverging into another package manager with sometime incompatible semantics.
This matter doesn’t warrant a package manager switch. That’s a huge knife for a small matter.

Hi @chenglou.

I am using the line from the official docs to scaffold the project:

git clone

Hi @Hongbo.

This seems indeed to be an issue.

I have tested the install on

  • Windows 10
  • MacOS Catalina, 10.15.6

On both the install was quick and node_modules takes up to 150MB.

Opened an issue: