I want to learn backend using node.js on my computer but the npm command is not working. When I say it’s not working, I mean I want to install a file and it doesn’t give any errors but I can’t use the packages.
npm i cors
up to date, audited 852 packages in 6s
found 0 vulnerabilities
Also it’s packet.json
{
"name": "deneme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "*",
"express": "*",
"nodemon": "*"
}
}
It doesn’t show in the versions after installation
const express = require('express')
const app = express()
app.listen(4000 , () => {
console.log('hello');
})
node deneme.js
node:internal/modules/cjs/loader:1145
throw err;
^
Error: Cannot find module 'express'
Require stack:
- C:*******Desktopdenemedeneme.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
at Module._load (node:internal/modules/cjs/loader:983:27)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (C:*******Desktopdenemedeneme.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) {
code: 'MODULE_NOT_FOUND',
Tried Solutions:
-Tried different npm versions.
-Checked the PATH variable.
-Ran commands as administrator.
-Cleared the npm cache (I cant because its not working )
Does anyone know the reason for the issue and how to fix it?
I tried to download ‘npm i cors’ and other packages, but it didn’t work. Something is blocking it, but I couldn’t solve it. I already provided the details above