Experimenting with the experimental in Node 20 and beyond
I took 30m to experiment with Node v20 yesterday, initially focused on experimental permissions. I noticed features that have been introduced since Node 14 that apply to Sports Card Investor’s engineering org, e.g. corepack.
Node/CorePack
One of those is Node’s corepack, which holds pnpm as an add’l official package manager that it will manage for you. You enable corepack like so. You declare which package manager and version thereof your Node project is using like so
Node::Test
Another is the introduction of the Node-native test
package, which works really nicely with assert
. assert
has always been useful for Node projects but the introduction of test makes it so that jest is just not necessary for many projects
Experimental Permissions
Node 20 now has a method for locking down which system aspects your code can access & have side effects on. I’m predicting that this feature will also be useful for debugging issues related to third-party code interacting with the file system (e.g. “what the hell is mutating this file?”). Here is an example of making FS permissions read-only and limited to the current directory & its descendents. Experimental Node API usage triggers warning messages by default, I’ve also used an environment variable to silence those—the point of that repo is using experimental APIs
Tying it all together
By running these tests with pnpm
I’m combining corepack
, test
& --experimental-permissions
to verify that FS reads are enabled in the project directory, while FS writes are not