74

I am setting up a new project with express+ typescript and facing typescript error - cann't find name 'processs'enter image description here

package.json

"dependencies": {
    "express": "^4.16.4",
    "nodemon": "^1.18.7",
    "tsc": "^1.20150623.0",
    "typescript": "^3.1.6"
  },
  "devDependencies": {
    "@types/express": "^4.16.0",
    "@types/mocha": "^5.2.5",
    "@types/node": "^10.12.10",
    "eslint": "^5.9.0",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-promise": "^4.0.1",
    "mocha": "^5.2.0",
    "supertest": "^3.3.0",
    "typescript-eslint-parser": "^21.0.1"
  }

I tried to follow the solution and added types tsconfig

{
    "compilerOptions": {
      "target": "es6",
      "module": "commonjs",
      "outDir": "dist",
      "sourceMap": true,
      "types": ["node"] -----
    },
    "include": [
      "src/**/*.ts"
    ],
    "exclude": [
      "node_modules"
    ]
}

But I still get the error. I have installed npm (6.4.1) and node (8.14.0) to start building up my new project. Can someone highlight what I am doing wrong?

user269867
  • 3,266
  • 9
  • 45
  • 65

5 Answers5

75

Your new configuration looks right. Although, you probably have to restart typescript language server if it still uses previous version of the tsconfig. In order to do this in VS Code, you do Ctrl+Shift+P and Reload Window or TypeScript: Restart TS server if available.

Also you don't need tsc package in your dependencies, because it is deprecated now, and typescript package comes with tsc executable.

Alex Yatkevich
  • 1,296
  • 10
  • 11
  • 14
    Just to point out that it's the `@types/node` dev dependency that seems to be required to fix this issue. At least, that's what got rid of the error for me. – devklick Jul 08 '21 at 08:42
  • 1
    You may also need a tsconfig.json file https://www.typescriptlang.org/docs/handbook/tsconfig-json.html – igneosaur Aug 25 '21 at 09:28
  • 1
    I did `yarn add -D @types/node`, then I restarted the TS server, and now it works. I don't have a `tsconfig.json`, using Node.js v18.9.0 – netotz Sep 17 '22 at 20:00
73

Make sure you have "types": ["node"] in your tsconfig.app.json file. Having it in tsconfig.json was not enough for me (Angular 12).

{
  ...
  "compilerOptions": {
    ...
    "types": ["node"]
  },
 ...
}

fix
  • 1,425
  • 16
  • 27
24

Just to point out that it's the @types/node dev dependency that seems to be required to fix this issue. At least, that's what got rid of the error for me. – devklick Jul 8 at 8:42

Using npm:

npm i --save-dev @types/node

Using Yarn: (@netotz)

yarn add -D @types/node
Steven Almeroth
  • 7,758
  • 2
  • 50
  • 57
  • Following this yielded ```npm ERR! 404 '@typescript-eslint/type-utils@https://registry.npmjs.org/@typescript-eslint/types-utils/-/types-utils-5.19.0.tgz' is not in the npm registry.``` – plutownium May 25 '22 at 22:56
  • `yarn add -D @types/node` – netotz Sep 17 '22 at 20:01
5

I got the error in /test/*.spec.ts files only.

I didn't want to add @types/node to my main dependencies.

For me, updating my tsconfig.json as follows fixed it:

  "include": [
    "src/**/*.ts",
    "test/**/*.spec.ts"
  ],
David Carboni
  • 1,556
  • 23
  • 24
0

Here I had a similar issue, that the --save-dev didnt work, so I would say add the @types/node as a normal dependency instead of a dev one.

enter image description here

  • 3
    You don't need types as dependency because you only use it while developing hence why it's in devDependencies. – A1rPun Oct 16 '22 at 17:49
  • @A1rPun but this indeed fixed my problem too. It works when I run it, but for some reason, VS Code type errors unless the types are not in dependencies. – GolDDranks May 23 '23 at 09:50
  • @GolDDranks I think that worked for you as when we are adding on dependecies we can do npm install, and this will be installed on node_modules, if the type isn't on node_modules would be hard to use them. I would say if you want to add as devDependecies you also need to install: npm install --only=dev I think after this you will be able to make it work as devDependecy. I hope this helps! – Jose Rafael Mendes Barbosa May 25 '23 at 12:48