question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v5 and evergreen-ui: Failed to parse source map from <package>

See original GitHub issue

Describe the bug

I’m trying to use evergreen-ui vanilla CRA v5 with the default build template. I follow the recommended steps to install both. Then I add a single evergreen-ui component to App.tsx, and the build returns many errors like the following:

WARNING in ./node_modules/ui-box/dist/src/value-to-string.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/andy/dev/aviation/sw/node_modules/ui-box/src/value-to-string.ts' file: Error: ENOENT: no such file or directory, open '/Users/andy/dev/aviation/sw/node_modules/ui-box/src/value-to-string.ts'
 @ ./node_modules/ui-box/dist/src/get-css.js 15:42-70
 @ ./node_modules/ui-box/dist/src/enhancers/borders.js 15:34-55
 @ ./node_modules/ui-box/dist/src/enhancers/index.js 23:29-49
 @ ./node_modules/ui-box/dist/src/index.js 39:14-42
 @ ./node_modules/evergreen-ui/esm/index.js 3:0-43 3:0-43
 @ ./src/App.js 6:0-38 12:35-41
 @ ./src/index.js 7:0-24 11:33-36

These errors occur with other packages I’m using as well, like zod. Evergreen-ui is probably more widely-known, so I’m using it as the example in this issue.

Did you try recovering your dependencies?

Yes. I’ve tried reproducing the issue using fresh installs in a new directory, too.

Which terms did you search for in User Guide?

source-map-loader, failed to parse source map, source map

Environment

Environment Info:

  current version of create-react-app: 5.0.0
  running from /Users/andy/.npm/_npx/19074/lib/node_modules/create-react-app

  System:
    OS: macOS 12.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.17.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.13 - /usr/local/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Edge: Not Found
    Firefox: 95.0.2
    Safari: 15.2
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: 5.0.0 => 5.0.0
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

npx create-react-app error-project
cd error-project
npm install evergreen-ui
npm start
# OR `npm build` (both have the same error messages)

My App.tsx looks like this:

import logo from "./logo.svg";
import "./App.css";
import { Select } from "evergreen-ui";

function App() {
  return (
    <div className="App">
      <Select>
        <option value="blah" />
      </Select>
    </div>
  );
}

export default App;

If I disable sourcemaps, the error output goes away

GENERATE_SOURCEMAP=false npm start
GENERATE_SOURCEMAP=false npm build

Expected behavior

Sourcemaps are generated (since they’re enabled by default) and there are no ‘failed to parse source maps’ error messages.

Reproducible demo

Clone this repo, npm install, then npm start or npm build: https://github.com/aaltepet/cra-v5-sourcemap-errors

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
alspdxcommented, Jan 20, 2022

The problem is that the library’s source files are being referenced but not being published, just the compiled code in the dist directory. I’m also having this issue with zod, there’s an open issue about it and a PR to publish the source files which would fix the problem.

Webpack can be configured to ignore specific warnings, but I imagine that isn’t the best default configuration for everyone using CRA. Would be nice if we had an option to silence these warnings since it will be up to individual package maintainers to fix their own code, and not everyone is going to be sympathetic to this issue.

6reactions
andrejcremoznikcommented, Feb 11, 2022

I don’t think ejecting and overriding webpack config here is the right solution. There are just too many libraries shipping dist files only so this needs to be supported out of the box by CRA. In my case it’s https://github.com/zxing-js/browser

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to parse source map - Stack Overflow
In the node_modules folder I have the @AAA/BBB folder with /dist/cjs and /dist/esm. I dont know what can produce the search in /src...
Read more >
Fixing sourcemap errors in Webpack 5 - Ionic React
However, when I run npm run serve , I noticed I am getting several sourcemap errors: [react-scripts] Failed to parse source map from ......
Read more >
upgrading to webpack 5 causes sourcemap issues : r/typescript
node_modules/source-map-loader/dist/cjs.js): Failed to parse source map ... in the package tsconfig , I have enabled sourcemap generation, ...
Read more >
0 - You.com
Package subpath './lib/parser' is not defined by "exports" in /home/node/app/node_modules/postcss/package.json I am getting an error like this .
Read more >
@segment/consent-manager - npm package | Snyk
Drop-in consent management plugin for analytics.js For more information about how to use this package see README. Latest version published 5 days ago....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found