Categories
JavaScript Answers

How to import node’s path module using import path from ‘path’ with Node.js?

Spread the love

To import node’s path module using import path from ‘path’ with Node.js, we add the type definitions for node.

And the we import the module.

To install the type definitions, we run

npm install --save-dev @types/node

Then we import path with

import * as path from 'path';

to import all members into the path object.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *