Parcel serve: Got unexpected null
See original GitHub issue🐛 bug report
I’ve been getting this error when running parcel serve a couple times today
ℹ️ Server running at http://localhost:1234
✨ Built in 3.71s
Error: Got unexpected null
at nullthrows ([project_dir]node_modules/nullthrows/nullthrows.js:7:15)
at PackagedBundle.get filePath [as filePath] ([project_dir]node_modules/@parcel/core/lib/public/Bundle.js:367:38)
at [project_dir]node_modules/@parcel/reporter-dev-server/lib/Server.js:272:104
at Array.find (<anonymous>)
at Server.serveBundle ([project_dir]node_modules/@parcel/reporter-dev-server/lib/Server.js:272:45)
at Server.respond ([project_dir]node_modules/@parcel/reporter-dev-server/lib/Server.js:219:19)
at [project_dir]node_modules/@parcel/reporter-dev-server/lib/Server.js:440:14
at call ([project_dir]node_modules/connect/index.js:239:7)
at next ([project_dir]node_modules/connect/index.js:183:5)
at Function.handle ([project_dir]node_modules/connect/index.js:186:3) {
framesToPop: 1
}
npm ERR! code 1
npm ERR! path [project_dir]
npm ERR! command failed
npm ERR! command sh -c ./build_scripts/serve
I’ve tried cleaning the cache and it didn’t help. It happens after like the 2nd or 3rd request.
Unfortunately when I tried to actively reproduce it it stopped and has been working since 😦 I’ll update with more info if it happens again. I have a new laptop so maybe something’s not set up correctly.
🎛 Configuration (.babelrc, package.json, cli command)
package.json
{
"scripts": {
"serve": "dotenv -e .env.development -- parcel serve --port 1234 --target dev --no-cache --no-hmr --dist-dir dev_dist/myscript src/main.ts",
},
"targets": {
"dev": {
"engines": {
"browsers": "last 1 firefox version"
}
}
},
"devDependencies": {
"@babel/cli": "latest",
"@babel/core": "latest",
"@babel/plugin-proposal-class-properties": "latest",
"@babel/plugin-proposal-private-methods": "latest",
"@babel/preset-typescript": "latest",
"@parcel/babel-plugin-transform-runtime": "nightly",
"@parcel/babel-preset-env": "nightly",
"@parcel/optimizer-cssnano": "nightly",
"@parcel/optimizer-htmlnano": "nightly",
"@parcel/packager-css": "nightly",
"@parcel/packager-html": "nightly",
"@parcel/transformer-css": "nightly",
"@parcel/transformer-html": "nightly",
"@parcel/transformer-inline-string": "nightly",
"@parcel/transformer-postcss": "nightly",
"@parcel/transformer-posthtml": "nightly",
"parcel": "nightly",
"segfault-handler": "latest",
"terser": "latest"
},
"dependencies": {
"@babel/runtime": "latest",
"@babel/runtime-corejs3": "latest",
"dotenv-cli": "latest"
}
}
.babelrc:
{
"presets": ["@babel/preset-typescript", "@parcel/babel-preset-env"],
"plugins": ["@parcel/babel-plugin-transform-runtime"]
}
🤔 Expected Behavior
Parcel serve should not crash.
😯 Current Behavior
It crashes sometimes.
💁 Possible Solution
Never crash.
🔦 Context
Wanted to continue developing my script and wondered why nothing happened.
💻 Code Sample
I’ll post one if I manage to reproduce it with something that’s not my whole code
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.0.0-nightly.630+ed726670 |
| Node | v15.12.0 |
| npm | 7.6.3 |
| Operating System | macOS Catalina 10.15.7 (19H15) |
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Parcel Build Error: Error: Key 216aea59fec25090 not found in ...
Parcel Build Error: Error: Key 216aea59fec25090 not found in cache/Error: Got unexpected null at nullthrows.
Read more >TypeScript - Parcel
TypeScript is a typed superset of JavaScript that compiles to JavaScript. Parcel supports TypeScript out of the box without any additional configuration.
Read more >ClassNotFoundException when using custom Parcelable ...
So, the Intent object read from parcel always get a null class loader and create a PathClassLoader from base class path. I personally...
Read more >globalThis - JavaScript - MDN Web Docs
Prior to globalThis , the only reliable cross-platform way to get the global object for an environment was Function('return this')() .
Read more >Service | Android Developers
This means that, if your service is going to do any CPU intensive (such as ... To invoke the bound service, first make...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s intentional that inline bundles don’t have a file path, as they are never written to disk directly (and namer plugins aren’t invoked for them).
So the fix would be adding
.filter(b => !b.isInline)here: https://github.com/parcel-bundler/parcel/blob/dea272f0708fdabfe11f844f189df6421e7a3b65/packages/reporters/dev-server/src/Server.js#L209I just got this error as well, looks like it was caused by an inline CSS bundle that was created because of
<style></style>tags.Inline bundles do indeed not have a filepath …