There's a post out there on how to try the JavaScript pipeline operator in Node, but it's a little out of date. Babel removed its Stage presets, so the instructions given there won't work anymore. Here's what to do now.
First, make and navigate into a new directory, and run this:
$ npm init -y $ npm install --save @babel/cli @babel/core @babel/plugin-proposal-pipeline-operatorThis gives you a
package.json
file and installs the Babel transpiler and the plugin to handle the pipeline operator.
Next, create a file in your new directory called .babelrc
with the following contents:
{ "plugins": [ ["@babel/plugin-proposal-pipeline-operator", { "proposal": "minimal" }], ] }Then, in your
package.json
, add this line to the scripts
object:
"start": "babel pipe.js --out-file output.js && node output.js"
Now make a file called pipe.js
and add some code that uses the pipeline operator to it. You'll be able to run this file with npm start
.