framework icon indicating copy to clipboard operation
framework copied to clipboard

Add a switch between npm and yarn in the docs

Open eagereyes opened this issue 2 years ago • 3 comments

For npm users to be able to copy code, we should add a switch on the config page to flip between yarn and npm.

yarn observable subcommand translates to npx observable subcommand, yarn build would be npm run build.

These will obviously need to be tested with both before we add this.

eagereyes avatar Jan 12 '24 00:01 eagereyes

npx is something different — it is typically used to run something that you haven’t explicitly installed. It will download and then run it. So I don’t think we want to recommend npx here, since we expect people to be installing the CLI locally into their project. Likewise, we don’t generally recommend that people yarn observable foo because we have scripts defined in package.json for that.

mbostock avatar Jan 16 '24 17:01 mbostock

npx does have that behavior, but before doing that it will check for packages installed in the local project and run those instead. As far as I know, it is the recommended way to run the binaries of locally installed packages for npm. It's annoying that it doesn't have a way to ensure you're only using the local version.

I agree that for the common tasks, we should have packaeg.json scripts. I'm not sure we want to have local package.json scripts for all possible subcommands of the observable CLI. For example, observable whoami and observable version don't seem suitable for package.json scripts to me.

Perhaps we should have a package.json script named "observable" like we have in this repo, so we can guarantee that it runs the local version. Then a command like login would be yarn observable login and npm run observable login. How does that sound?

mythmon avatar Jan 16 '24 19:01 mythmon

Yes, a package.json script named “observable” sounds useful. Let’s try that.

mbostock avatar Jan 16 '24 19:01 mbostock