Cannot find type definition file for 'node' in react project

22 Views Asked by At

I have node js project that running correctly on windows. When i trying to run this project on mac it didnt work, and throws me error:

11:59:03 AM - Starting compilation in watch mode...

error TS2688: Cannot find type definition file for 'node'.
  The file is in the program because:
    Entry point of type library 'node' specified in compilerOptions

11:59:08 AM - Found 1 error. Watching for file changes.

i deleted and reinstalled the node modules folder, i had installed the npm install --save @types/node, i add "types": ["node"] in the tsconfig.json, but the error still persist.

my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es2017",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "typeRoots": ["./@types"],
    "baseUrl": ".",
 

 

    "strict": false,              
    "noImplicitThis": false,        
    "allowSyntheticDefaultImports": true,  
    
    "paths": {
      "*": ["*", "components/*"]
    },
    "types": ["node"],
    "skipLibCheck": true
  },
  "exclude": [
    "node_modules"
  ],
  "lib": ["esnext", "es6", "es5", "es2017"]
}

my package.json file:

{
  "name": "courses-server",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "tsc-watch --onSuccess \"node ./dist/index.js\"",
    "dev-inspect": "tsc-watch --onSuccess \"env-cmd -f ./.env node --inspect ./dist/index.js\"",
    "dev-env": "tsc-watch --onSuccess \"env-cmd -f ./.env node   ./dist/index.js\"",
    "start": "tsc && node dist/index.js",
    "link-utils": "cp -R ../studentcher-shared-utils/src/* ./src/studentcher-shared-utils/ "
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@aws-sdk/client-s3": "^3.241.0",
    "@aws-sdk/s3-request-presigner": "^3.241.0",
    "@discordjs/voice": "^0.16.1",
    "@types/es6-promise": "^3.3.0",
    "@types/jsonwebtoken": "^9.0.4",
    "aws-sdk": "^2.1288.0",
    "bcrypt": "^5.1.0",
    "cors": "^2.8.5",
    "discord-api-types": "^0.37.21",
    "discord.js": "^14.12.1",
    "express": "^4.18.2",
    "express-http-proxy": "^1.6.3",
    "ioredis": "^5.2.5",
    "@types/node": "^18.19.26",
    "jsonwebtoken": "^9.0.2",
    "pg": "^8.8.0",
    "ws": "^8.14.2"
  },
  "devDependencies": {
    "@types/dotenv": "^8.2.0",
    "@types/ioredis": "^5.0.0",
    "@types/node": "^18.19.26",
    "@types/uuid": "^9.0.0",
    "env-cmd": "^10.1.0",
    "nodemon": "^2.0.16",
    "ts-node": "^10.9.1",
    "tsc-watch": "^5.0.3",
    "typescript": "^5.4.3",
    "webpack-cli": "^5.1.4"
  }
}
0

There are 0 best solutions below