Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

Module not found: Can't resolve '@babel/runtime/helpers/...'

ErrorModule not found: Can't resolve '@babel/runtime/helpers/objectWithoutPropertiesLoose'

Short answer

Babel can import its shared helper functions from the @babel/runtime package, under @babel/runtime/helpers, instead of copying them into each file. This error means that package is not in node_modules. Install it as a normal dependency, or reinstall cleanly from the lockfile if it is already listed.

  • Applies to Node.js 22, npm 10, Babel 7, webpack 5
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask npm whether @babel/runtime is installed, and who wants it. A missing result tells you which cause applies.

    npm ls @babel/runtime --all
  2. 2Match what you see, then jump to its fix

    1. 1npm ls does not list @babel/runtime, and your own babel config uses @babel/plugin-transform-runtime@babel/runtime is not in package.json at allFix
    2. 2package.json and package-lock.json both name @babel/runtime, yet the folder node_modules/@babel/runtime is missingIt is listed, but node_modules is incomplete or out of dateFix

What does the error look like?

  • Module not found: Can't resolve '@babel/runtime/helpers/objectWithoutPropertiesLoose'
  • Module not found: Error: Can't resolve '@babel/runtime/helpers/...'

Cause 1 of 2

@babel/runtime is not in package.json at all

1Check

The transform-runtime plugin replaces inline helper code with imports from @babel/runtime. The plugin is a dev dependency, but the helper package must be a production dependency, because the built code imports it.

grep -n -E 'babel/runtime|plugin-transform-runtime' package.json

2Fix

Install the package as a regular dependency.

npm install --save @babel/runtime

3Verify

Run the build or dev server again, and confirm the package now shows in the tree.

npm ls @babel/runtime
npm run build

Confirmed by babeljs.io

Did this fix it?

Cause 2 of 2

It is listed, but node_modules is incomplete or out of date

1Check

npm ls reads the dependency tree and reports missing, invalid and extraneous packages. Check the folder as well.

npm ls @babel/runtime
ls node_modules/@babel/runtime/helpers | head

2Fix

Remove node_modules and install exactly what the lockfile says. npm ci deletes node_modules first and stops with an error if package.json and the lockfile disagree, which also exposes a half-updated lockfile.

npm ci

3Verify

The helper file exists and the build passes.

ls node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js
npm run build

Confirmed by docs.npmjs.com

Did this fix it?

How do I stop it coming back?

  • Install @babel/runtime with --save, never --save-dev, whenever a config uses plugin-transform-runtime.
  • Use npm ci in CI and in Docker builds, so the install matches the lockfile.
  • Commit the lockfile after every dependency change.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Web apps

tsconfig rejects allowImportingTsExtensions

An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.