Module not found: Can't resolve '@babel/runtime/helpers/...'
Module 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.
Fix it fast
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 --all2Match what you see, then jump to its fix
- 1
npm 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
package.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
- 1
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.json2Fix
Install the package as a regular dependency.
npm install --save @babel/runtime3Verify
Run the build or dev server again, and confirm the package now shows in the tree.
npm ls @babel/runtime
npm run buildConfirmed by babeljs.io
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 | head2Fix
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 ci3Verify
The helper file exists and the build passes.
ls node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js
npm run buildConfirmed by docs.npmjs.com
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 fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fix