From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Write Node.js-based code and script

Write Node.js-based code and script

From the course: SharePoint Framework for Developers: 1 Understanding the Toolchain

Start my 1-month free trial

Write Node.js-based code and script

- [Instructor] At this point I have created a node based project and my package.json depends on another node module called moment.js. Now I'm ready to start taking advantage of moment.js using it in my code. How do we go about doing that? We're keeping this to pure Node.js so we can actually use ES6. So I'm going to create a new file called index.js. Note there is no TypeScript here yet. And let's go ahead and write some code in this index.js file. So I'm going to say var moment = require('moment') . Notice that the VSCode intellisense picks this up and that is very, very useful. Let's talk a moment for what exactly this require statement will do. require will look for moment.js inside of the current folder. If it doesn't find it there, it'll look inside a folder called moment inside node_modules Inside the moment folder, it'll by default, look for a file called index.js. But, otherwise, it will also look for a file called package.json. Remember, I have a package.json in my node based…

Contents