Why do npm packages resolve from /AppData and not from local /node_modules?

Viewed 897

When developing locally in VS Code, packages are resolving to C:/Users/<User>/AppData/Local/Microsoft/TypeScript/3.5/node_modules/@types/<package>/index and not from the /node_modules directory local to the package.json.

I'm not getting any compiling errors or when deploying, but I can't wrap my head around why it's not resolving to the location I'd expect it to. Any idea why and how to fix it?

I'm using Node 8.12 and NPM 6.4.1.

Here's an example screenshot example

package.json

{
  "name": "superapp",
  "version": "0.0.1",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "node server"
  },
  "keywords": [],
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "dotenv": "^8.0.0",
    "express": "^4.17.1"
  }
}
1 Answers

Your module in question @types/express is not present in package.json

npm install @types/express --save-dev

You may have installed it globally previously and that is why it can be found in AppData as a backup solution for the compiler

Related