How to find module “fs” in MS Code with TypeScript?

1326
1
08-26-2020 08:46 AM
RoseZhou2
Occasional Contributor

Hi, I have include a definition file for node by running following command: npm install --save-dev @types/node
Also included it in package.json:


"devDependencies": {
"@types/arcgis-js-api": "^4.12.0",
"@types/node": "^14.6.0",
"dojo-typings": "1.11.9",
"npm-run-all": "^4.1.3",
"reload": "2.3.1",
"rimraf": "^2.6.2",
"typescript": "3.9.7"
}

When execute this line of code "const fs=require("fs");", it looks for the module in JS 4.12 instead of "node", and  complains "undefinedModule".

Any ideas?

Regards

Rose

1 Reply
BenjaminCumberland
New Contributor III

As I'm getting started on learning Typescript, Node, NPM, and everything else, this is one that I'm also running into. I'm trying to run something similar with the require function to get a local JSON file, but it continues to fail within the JSAPI (4.17) when I believe it should be running a different require method.

0 Kudos