Skip to main content

When using @amplitude/plugin-web-vitals-browser with Create React App v4 (react-scripts@4.0.3), the build fails with:

 

./node_modules/@amplitude/plugin-web-vitals-browser/node_modules/web-vitals/dist/web-vitals.js

SyntaxError: /app/node_modules/@amplitude/plugin-web-vitals-browser/node_modules/web-vitals/dist/web-vitals.js: Missing class properties transform.

This happens because CRA v4’s Babel config doesn’t support class fields syntax, which web-vitals (an amplitude dependency) uses.

Upgrading to react-scripts@5 fixes the issue, but it introduced conflicts with dotenv in my setup. I had to uninstall dotenv to proceed.

It would help if the package were transpiled for CRA v4 compatibility, or if documentation clearly stated that CRA v5+ is required.

Be the first to reply!