Then install parcel with npm globally -> npm i -g parcel-bundler
After that, you can type "parcel index.html" in the console and it will be available on localhost:1234 and you can check the output in the console of the browser.
Parcel is a zero-configuration web application bundler by the way.
If you want to run it with node, you can do node ./index.js in the console, but it will fail because of the "import { blabla } from "something" syntax.
You can change the export statements to the following (example):
The easiest way to run the examples is parceljs.
Create an index.html in the same directory. Include your index.js in it like this.
Then install parcel with npm globally ->
npm i -g parcel-bundler
After that, you can type "parcel index.html" in the console and it will be available on localhost:1234 and you can check the output in the console of the browser.
Parcel is a zero-configuration web application bundler by the way.
If you want to run it with node, you can do
node ./index.js
in the console, but it will fail because of the "import { blabla } from "something" syntax.You can change the export statements to the following (example):
and then import it in your index.js
const { BinarySearchTree} = require("./BinarySearchTree")
If you don't want to change the code, you can setup babel with node as well.
(this is babel6, for babel7 please check the official documentation)
step1:
npm -i babel-cli babel-preset-env
step2: create a
.babelrc
file that looks like this:step3: run your index.js with the following command:
./node_modules/.bin/babel-node index.js
Cool, I use parcel, thanks Braun really.