{ Error: [BABEL]: Cannot find module '@babel/helper-environment-visitor'

Hello People,

I am getting errors with @BABEL error

  • yarn workspace @hims/api build
    yarn workspace v1.22.4
    yarn run v1.22.4
    warning package.json: License should be a valid SPDX license expression
    $ babel src -d dist
    { Error: [BABEL]: Cannot find module ‘@babel/helper-environment-visitor’ (While processing: /var/lib/jenkins/workspace/xdev-system-admin-pl/@hims/api/node_modules/@babel/plugin-proposal-class-properties/lib/index.js)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object. (/var/lib/jenkins/workspace/xdev-system-admin-pl/node_modules/@babel/helper-create-class-features-plugin/node_modules/@babel/helper-replace-supers/lib/index.js:26:33)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions…js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3) code: ‘MODULE_NOT_FOUND’ }
    error Command failed with exit code 1.
    info Visit yarn run | Yarn for documentation about this command.
    error Command failed.
    Exit code: 1
    Command: /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/nodeJS_10.19/bin/node
    Arguments: /usr/share/yarn/lib/cli.js build
    Directory: /var/lib/jenkins/workspace/xdev-system-admin-pl/@hims/api
    Output:

info Visit yarn workspace | Yarn for documentation about this command.

the last build was ok, but then, after the next build, We get this error.

We tried to do the troubleshoot like, changing/removing old babel in the yarn.lock, doing the yarn upgrade, still we are getting errors.

Please help! THank you!

It’s not really a jenkins issue. Something has changed on your end. Without seeing all your code, or knowing anything about your environment, it’s really hard to give you much help.

Based on the first google search. I found Cannot find module '@babel/helper-environment-visitor' · Discussion #14069 · babel/babel · GitHub which seems to imply that you’re not using a lock file, so your install command is always pulling the latest matching version.