typescript cannot find module js file code example
Example 1: Cannot find module 'typescript'
# NPM Installation Method
npm install --global typescript # Global installation
npm install --save-dev typescript # Local installation
#Yarn Installation Method
yarn global add typescript # Global installation
yarn add --dev typescript # Local installation
Example 2: cannot find module typescript
npm install -g typescript
Example 3: error TS2307: Cannot find module 'path' or its corresponding type declarations.
go to 'tsconfig.app.json' and add "node" to types:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": ["node"] <------------ ADD "node" HERE
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}