1

I have one problem. I'm trying to import node_modules in typescript but I'm getting an error

"[ts] Cannot find module 'path'."

This is my code :

import path from 'path';

2 Answers 2

5

You have to install @types/node (you may want to add --save-dev or --save).

$ npm install @types/node

Then, in your code,

import * as path from 'path';
Sign up to request clarification or add additional context in comments.

Comments

0

Try the following:

import * as path from 'path';

2 Comments

I'm getting same problem error TS2307: Cannot find module 'path'.
Update your question with your tsconfig file please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.