From 60d8c8ad4c805bd262e58970ab643a37eb4f68e8 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 22 Sep 2024 00:17:41 -0700 Subject: [PATCH] Update from-npm-install-to-bun-install.md --- .../from-npm-install-to-bun-install.md | 176 ++++++++++++------ 1 file changed, 124 insertions(+), 52 deletions(-) diff --git a/docs/guides/install/from-npm-install-to-bun-install.md b/docs/guides/install/from-npm-install-to-bun-install.md index ca3137834f6c85..07c9c8ea1b9736 100644 --- a/docs/guides/install/from-npm-install-to-bun-install.md +++ b/docs/guides/install/from-npm-install-to-bun-install.md @@ -2,104 +2,109 @@ name: Migrate from npm install to bun install --- -`bun install` is a Node.js compatible npm client designed to be an incredibly fast replacement for `npm install`. +bun install is a Node.js compatible npm client designed to be an incredibly fast replacement for npm. We've put a lot of work into making sure that the migration path from `npm install` to `bun install` is smooth and automatic. - **Designed for Node.js & Bun**: `bun install` installs a Node.js compatible `node_modules` folder. You can use it in place of `npm install` for Node.js projects without any code changes. -- `bun install` automatically converts `package-lock.json` to bun's `bun.lockb` lockfile format, preserving your existing resolved dependency versions without any manual work on your part -- `bun install` reads npm registry configuration from npm's `.npmrc` as well as Bun's bunfig.toml +- **Automatically converts `package-lock.json`** to bun's `bun.lockb` lockfile format, preserving your existing resolved dependency versions without any manual work on your part. You can secretly use `bun install` in place of `npm install` at work without anyone noticing. +- bun install reads npm registry configuration from npm's `.npmrc` as well as Bun's bunfig.toml - On Windows and Linux, `bun install` uses hardlinks to conserve disk space and install times -To migrate from `npm install` to `bun install`, run `bun install`: - ```bash +# It only takes one command to migrate $ bun i -``` -## Run package.json scripts and executables with `bun run` +# To add dependencies: +$ bun i @types/bun -To run a package.json script, you can use `bun `. - -```sh -$ bun my-script +# To add devDependencies: +$ bun i -d @types/bun -# This also works: -$ bun run my-script +# To remove a dependency: +$ bun rm @types/bun ``` -This works for: +--- -- package.json `"scripts"` (`npm run` equivalent) -- executables in `node_modules/.bin` (`npx` equivalent, for already-installed packages) -- JavaScript & TypeScript files (just like `node`) +## Run package.json scripts faster -If you're coming from npm, you might be used to running scripts with `npm run