DEV Community

Discussion on: New Node.js protocol imports

Collapse
 
bennycode profile image
Benny Code

I just tried to use import fs from 'node:fs' with TypeScript but the TypeScript compiler tells me "TS2307: Cannot find module 'node:fs' or its corresponding type declarations.". Do you know what I am doing wrong?

Collapse
 
yenyih profile image
Jordan Soo Yen Yih • Edited

Hi , it supported in TypeScript by the latest versions of @types/node. However I haven't try in Typescript yet. Maybe you can double check on the @types/node version you are using. You may refer the Github issue here

Collapse
 
bennycode profile image
Benny Code

Cool. I just tried it wih @types/node v16.11.20 and can confirm it works! I suggest adding it to your article. Thanks for showing me this! :)

Thread Thread
 
yenyih profile image
Jordan Soo Yen Yih

Great👏🎉. Thank you for the verify too. I already added into the article. 😊