I get a MODULE_NOT_FOUND error after successfully installing the external module "file" with npm. It appears in the project folder with all its files as usual, the dependencies in the json file are also there. It happens with every npm package. I already reinstalled npm and tried different LTS versions of npm. I double checked the json file that the dependencies are corret.
This is the error message:
phila@DESKTOP-68STT9S MINGW64 /g/My Drive/Work - Software/WebDevelopmentCourse/Web Development/introNPMNODE
$ node test.js
node:internal/modules/cjs/loader:959
throw err;
^
Error: Cannot find module 'file'
Require stack:
- G:\My Drive\Work - Software\WebDevelopmentCourse\Web Development\introNPMNODE\test.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (G:\My Drive\Work - Software\WebDevelopmentCourse\Web Development\introNPMNODE\test.js:1:12)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'G:\\My Drive\\Work - Software\\WebDevelopmentCourse\\Web Development\\introNPMNODE\\test.js'
]
}
This is the json file:
{
"name": "intronpmnode",
"version": "1.0.0",
"description": "test",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "phil",
"license": "ISC",
"dependencies": {
"core-util-is": "^1.0.3",
"file": "^0.2.2"
}
}
the javascript "test.js" file:
var file = require("file");