From the course: Node.js: Web Servers, Tests, and Deployment

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Using import statements

Using import statements

- [Instructor] So far when we've been working with Node.js we have imported items using the require statement, and then once they are imported we can start to log some of these things. So let's go ahead and try to run this. We're going to make sure that we're in our start folder, and then we're going to run node index to make this work. Now this will give me a little bit of information about our file system module. Whenever we have imported these modules in the past, whether they come from NPM or whether they just come from Node.js itself, we have used the require statement using a pattern called CommonJS to import these modules. Now you may have seen a different syntax used which looks a little something like this, import fs from fs. Both of these lines of code are doing the same thing. We're saying, "Let's import this so that I can use this file system module." But the import statements were something that never used to…

Contents