'Can not find module: @babel/register' when 'yarn'

1k Views Asked by At

I'm having trouble installing yarn. This is because of the error 'Can not find module: @babel/register'.

To solve this problem, I tried $npm cache verify, $npm cache clean -force and $yarn cache clean.

Also I deleted node-modules, package.lock.json, yarn-lock, but it isn't work.

I also looked at BabelRegister.js,webpack.config.eslint.js and there was no problem like other solutions.

I'm using electron-react-boilerplate and @babel/register is already installed.

And after deleting them all, I tried clone again, but the same error occurs again.

Even with $npm i, and I deleted yarn and again $npm i -g yarn it's the same.

The Error when I install yarn

yarn install v1.22.11
[1/4] Resolving packages...
success Already up-to-date.
$ node -r @babel/register .erb/scripts/CheckNativeDep.js && electron-builder install-app-deps && yarn cross-env NODE_ENV=development webpack --config 
./.erb/configs/webpack.config.renderer.dev.dll.babel.js && opencollective-postinstall && yarn-deduplicate yarn.lock
internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module '@babel/register'
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1231:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:468:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:71:3)
    at internal/main/run_main_module.js:7:1 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'internal/preload' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

The same error when i $yarn add moment

yarn add v1.22.11
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "jquery@>=1.8.0".
warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
warning " > [email protected]" has incorrect peer dependency "electron@^7.0.0".
warning " > [email protected]" has incorrect peer dependency "react@^16.0.0-0".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.0.0-0".
warning "enzyme-adapter-react-16 > [email protected]" has incorrect peer dependency "[email protected] || 0.14.x || ^15.0.0-0 || ^16.0.0-0".   
warning "enzyme-adapter-react-16 > [email protected]" has incorrect peer dependency "react@^16.14.0".
warning "enzyme-adapter-react-16 > enzyme-adapter-utils > [email protected]" has incorrect peer dependency "react@^0.14 || ^15.0.0 || ^16.0.0-alpha".
warning " > [email protected]" has incorrect peer dependency "eslint-config-airbnb-typescript@^8.0.2".
warning " > [email protected]" has incorrect peer dependency "eslint-import-resolver-webpack@^0.12.2".
warning " > [email protected]" has incorrect peer dependency "eslint-plugin-jest@^23.13.2".
warning " > [email protected]" has incorrect peer dependency "[email protected]".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-testcafe@^0.2.1".
warning " > [email protected]" has incorrect peer dependency "react@^16.13.1".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
$ node -r @babel/register .erb/scripts/CheckNativeDep.js && electron-builder install-app-deps && yarn cross-env NODE_ENV=development webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.babel.js && opencollective-postinstall && yarn-deduplicate yarn.lock
internal/modules/cjs/loader.js:892
  throw err;
  ^

Error: Cannot find module '@babel/register'
Require stack:
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at Module._preloadModules (internal/modules/cjs/loader.js:1231:12)
    at loadPreloadModules (internal/bootstrap/pre_execution.js:468:5)
    at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:71:3)
    at internal/main/run_main_module.js:7:1 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'internal/preload' ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
0

There are 0 best solutions below