Skip to content

Migrating from npm or pnpm ​

craft works with the package.json you have. To try it on a project:

sh
rm -rf node_modules
craft install
craft test

The first install resolves from package.json and writes craft.lock. craft doesn't read package-lock.json, yarn.lock or pnpm-lock.yaml, so versions within your ranges may differ from what those lockfiles pinned. Once it works, commit craft.lock and delete the old lockfile.

Command equivalents ​

npmpnpmcraft
npm installpnpm installcraft install
npm cipnpm install --frozen-lockfilecraft ci
npm install reactpnpm add reactcraft add react
npm install -D vitestpnpm add -D vitestcraft add -D vitest
npm uninstall reactpnpm remove reactcraft remove react
npm updatepnpm updatecraft update
npm outdatedpnpm outdatedcraft outdated
npm lspnpm listcraft list
npm explain mspnpm why mscraft why ms
npm run buildpnpm buildcraft run build, or craft build
npx tscpnpm exec tsccraft exec tsc, or craft tsc
npx create-vitepnpm dlx create-vitecraft dlx create-vite
npm init -ypnpm initcraft init
npm cache clean --forcepnpm store prunecraft cache clean --force

What changes ​

Undeclared dependencies stop resolving. npm hoists every package to the top of node_modules, so code can accidentally require a dependency of a dependency. craft's root node_modules holds only what package.json lists, as with pnpm. If something breaks with Cannot find module, add the missing package to package.json. Dependencies that do this themselves keep working through hidden hoisting.

Dependencies' install scripts don't run until you trust them. craft lists the packages it skipped; most work anyway, and the ones that need to compile, such as bcrypt or sqlite3, need craft trust <name>. See Install scripts. pnpm users can move the names from onlyBuiltDependencies to trustedDependencies.

.npmrc keeps working for registries, auth, proxies and certificates. See Configuration.

Not supported yet ​

  • Workspaces (workspaces in package.json, pnpm-workspace.yaml, workspace: specifiers). A monorepo can't use craft yet.
  • overrides / resolutions / pnpm.overrides are ignored.
  • Importing an existing lockfile.
  • Global installs (npm install -g). Use craft dlx to run tools.
  • publish, pack, audit, link. Keep npm around for publishing.

Released under the MIT License.