Skip to main content

Import Export

@serverSerrverlesskiy

To make objects, functions, classes or variables ๐Ÿ”” available to the outside world, simply export them and then import them into other project files where necessary.

"Hello, World!" on Node.js#

Node.jsยฎ is a JavaScript environment built on the Chrome V8 engine.

Let's get started with Node.js just by typing node in the console:

$ node
>

If you don't have it, then download and install it on your computer.

Now let's try to print something:

$ node
> console.log('hello from Node.js')
// After hitting Enter, you get this:
hello from Node.js
undefined

Export

Feel free to experiment with Node.js using this interface: it is common to test small pieces of code here if it is not practical to put them directly into a file.

It's time to create our Hello Node.js application!

Let's start by creating the index.js file. With the next command we create the folder myProject and enter it.

mkdir myProject && cd myProject

Now we create the index.js file itself

touch index.js

Open your code editor or download and install it. We recommend VS Code.

Open the code editor and add the folder of the project we created to it.

new prroject

Now open the side menu by clicking this icon.

new prroject

Copy the following piece of code into it:

// index.js
console.log('hello from Node.js')

To run this file, you must reopen your terminal and navigate to the directory where index.js is located.

In VS Code this can be done by clicking on these icons.

new prroject

And choose the tab TERMINAL

new prroject

Once you have successfully navigated to the desired location, run the file using the command

node index.js

You will see that this command will produce the same output as before, printing the string directly to the terminal.

new prroject

Payment#

Now you are on a stripped-down version of the site, after subscribing to Patreon, you will get full access to the training course, as well as access to our server's private channels in Discord.

Download our mobile application or get tested in our JavaScript telegram bot, and also subscribe to our news.

Become a Patron!

Sumerian school

Contributors โœจ#

Thanks goes to these wonderful people (emoji key):


Dmitriy K.

๐Ÿ“–

Dmitriy Vasilev

๐Ÿ’ต

Resoner2005

๐Ÿ› ๐ŸŽจ ๐Ÿ–‹

Navernoss

๐Ÿ–‹ ๐Ÿ› ๐ŸŽจ

Become a Patron!