Parcel: Error messages are useless without info and stacktrace

Created on 10 Feb 2020  ยท  10Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report


Currently, the error messages (at least the ones I met) provide no helpful information on fixing the problem. Example:

Error: Asset not found
    at BundleGraph.getDependencies (/path/to/node_modules/@parcel/core/lib/BundleGraph.js:187:13)
    at BundleGraph.getDependencies (/path/to/node_modules/@parcel/core/lib/public/BundleGraph.js:104:48)
    at /path/to/node_modules/@parcel/reporter-dev-server/lib/HMRServer.js:79:44
    at Array.map (<anonymous>)
    at HMRServer.emitUpdate (/path/to/node_modules/@parcel/reporter-dev-server/lib/HMRServer.js:78:50)
    at Object.report (/path/to/node_modules/@parcel/reporter-dev-server/lib/ServerReporter.js:94:21)
    at ReporterRunner.report (/path/to/node_modules/@parcel/core/lib/ReporterRunner.js:69:31)
error Command failed with exit code 1.

With this error message, it is impossible to know what asset was not found and what is the import path to this asset error so that I can go there and fix it.

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

Using out of the box, run parcel serve index.html

๐Ÿค” Expected Behavior


It should at least be helpful showing the path where the issue happened and other related information, in the above case I expect at least the trace up until the import point of the missing file and what file is missing

๐Ÿ˜ฏ Current Behavior


It shows nothing and to the user it looks like a bug inside parcel instead

๐Ÿ”ฆ Context

๐Ÿ’ป Code Sample


I can't provide a sample as I don't know where the issue is happening.

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-alpha.3.2 |
| Node | 13.8.0 |
| npm/Yarn | 1.22.0 |
| Operating System | Arch Linux |

Bug โœจ Parcel 2

Most helpful comment

I suspect deleting the cache fixes that (a bug in Parcel when reusing the cache after a build error).

All 10 comments

Here's another example that's unhelpful:

๐Ÿšจ Build failed.
@parcel/packager-js: External modules are not supported when building for browser
Error: External modules are not supported when building for browser
    at Object.generateExternalImport (/path/to/node_modules/@parcel/scope-hoisting/lib/formats/global.js:50:9)
    at exit (/path/to/node_modules/@parcel/scope-hoisting/lib/link.js:559:23)
    at NodePath._call (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/path/context.js:55:20)
    at NodePath.call (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/path/context.js:42:17)
    at NodePath.visit (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/path/context.js:99:8)
    at TraversalContext.visitQueue (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/context.js:112:16)
    at TraversalContext.visitSingle (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/context.js:84:19)
    at TraversalContext.visit (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/context.js:140:19)
    at Function.traverse.node (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/index.js:84:17)
    at traverse (/path/to/node_modules/@parcel/scope-hoisting/node_modules/@babel/traverse/lib/index.js:66:12)
error Command failed with exit code 1.
  • External modules are not supported when building for browser does indeed point to a configuration issue, see https://github.com/parcel-bundler/parcel/issues/3761.

  • Asset not found means that Parcel's internal data structures are in a invalid state, this is a bug within Parcel itself. Can you provide a code sample?

While trying to isolate this bug and provide a sample, I ran into another issue: running yarn workspace @example/pkg1 build on this repo renders infinite building. Note the intentional invalid import of @example/shared, a package with no index file.

I just learned by adding a load of console.log to parcel's code that the "external modules not supported" error is happening on import React from 'react'. How am I supposed to use React with Parcel?

Edit: import './css/main.css' is also breaking. What is happening to my parcel install? It can't resolve anything! I do have "browser": "dist/index.html", in my package.json.

I do have "browser": "dist/index.html", in my package.json.

Don't use browser, main or module. These targets are meant for libraries and thus don't bundle node_modules.

@mischnic thanks, removing that leads to another error message without information:

Error: Got unexpected undefined
Error: Got unexpected undefined
    at nullthrows (/path/to/node_modules/nullthrows/nullthrows.js:7:15)
    at RequestGraph.removeById (/path/to/node_modules/@parcel/core/lib/Graph.js:188:40)
    at RequestTracker.untrackRequest (/path/to/node_modules/@parcel/core/lib/RequestTracker.js:286:16)
    at AssetGraphBuilder.handleNodeRemovedFromAssetGraph (/path/to/node_modules/@parcel/core/lib/AssetGraphBuilder.js:299:27)
    at AssetGraph.onNodeRemoved (/path/to/node_modules/@parcel/core/lib/AssetGraphBuilder.js:110:35)
    at AssetGraph.removeNode (/path/to/node_modules/@parcel/core/lib/AssetGraph.js:155:32)
    at AssetGraph.removeEdge (/path/to/node_modules/@parcel/core/lib/Graph.js:215:12)
    at AssetGraph.removeNode (/path/to/node_modules/@parcel/core/lib/Graph.js:179:14)
    at AssetGraph.removeNode (/path/to/node_modules/@parcel/core/lib/AssetGraph.js:156:18)
    at AssetGraph.removeEdge (/path/to/node_modules/@parcel/core/lib/Graph.js:215:12)
โ ธ Building index.js...

I suspect deleting the cache fixes that (a bug in Parcel when reusing the cache after a build error).

While trying to isolate the issue I ended up fixing it somehow. It seems to be related to aliases, which I have replaced with depending on sibling packages (it's a monorepo).

@mischnic deleting the cache did fix the previous issue.

I'll keep the issue open as I think the messages still should be reviewed.

I agree, these errors are really not very helpful. For example:

๐Ÿšจ Build failed.
@parcel/packager-js: This experimental syntax requires enabling the parser plugin: 'classProperties' (10:8)
SyntaxError: This experimental syntax requires enabling the parser plugin: 'classProperties' (10:8)
    at Parser.raise (/path/to/node_modules/@babel/parser/lib/index.js:7017:17)
    at Parser.expectPlugin (/path/to/node_modules/@babel/parser/lib/index.js:8400:18)
    at Parser.parseClassProperty (/path/to/node_modules/@babel/parser/lib/index.js:11695:12)
    at Parser.pushClassProperty (/path/to/node_modules/@babel/parser/lib/index.js:11657:30)
    at Parser.parseClassMemberWithIsStatic (/path/to/node_modules/@babel/parser/lib/index.js:11590:14)
    at Parser.parseClassMember (/path/to/node_modules/@babel/parser/lib/index.js:11527:10)
    at withTopicForbiddingContext (/path/to/node_modules/@babel/parser/lib/index.js:11482:14)
    at Parser.withTopicForbiddingContext (/path/to/node_modules/@babel/parser/lib/index.js:10565:14)
    at Parser.parseClassBody (/path/to/node_modules/@babel/parser/lib/index.js:11459:10)
    at Parser.parseClass (/path/to/node_modules/@babel/parser/lib/index.js:11433:22)

Why doesn't parcel tell me which one of my source files is causing the problem? (I understand in this case why the problem is occurring, but in this and other cases it would be nice to know which source file is the cause).

Closing this since it has become an umbrella for "bad error message", please open individual issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donaldallen picture donaldallen  ยท  3Comments

oliger picture oliger  ยท  3Comments

will-stone picture will-stone  ยท  3Comments

termhn picture termhn  ยท  3Comments

Niggler picture Niggler  ยท  3Comments