Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module '@babel/parser'

I am no longer able to transpile my codebase when running babel. I made. It wasn't happening before and I am unable to figure out why. This only happened when I pulled remote master branch, which had yarn.lock conflicts. I resolved conflicts with the yarn commands.

here is part of my package.json

{
  "devDependencies": {
    "@babel/cli": "^7.1.0",
    "@babel/core": "^7.1.2",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.0.0",
    "@babel/plugin-proposal-export-default-from": "^7.0.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
    "@babel/plugin-proposal-function-sent": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.1.0",
    "@babel/polyfill": "^7.0.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-react": "^7.0.0",
    "@babel/register": "^7.0.0",
    ...
  }
}

Running babel src -d build results in the following error

{ Error: Cannot find module '@babel/parser'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at _parser (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/normalize-file.js:59:16)
    at parser (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/normalize-file.js:170:18)
    at normalizeFile (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/normalize-file.js:138:11)
    at runSync (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/index.js:44:43)
    at runAsync (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/index.js:35:14)
    at /Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transform-file.js:58:36 code: 'MODULE_NOT_FOUND' }

I also tried deleting node_modules and run yarn install with no luck.

like image 251
mmohammad Avatar asked Jul 10 '26 04:07

mmohammad


2 Answers

For me the solution was to delete the node_modules folder, and reinstall

rm -rf node_modules
yarn
like image 106
Liran H Avatar answered Jul 14 '26 00:07

Liran H


Was able to resolve the issue by simply bumping babel-eslint from 8.2,3 to 10.0.1

like image 35
mmohammad Avatar answered Jul 14 '26 00:07

mmohammad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!