I'm getting the an error on terminal while trying to compile the code, but I don't understand why.
Code:
const express = require("express");
const app = express();
console.dir(app);
Error:
package.json:
{
"name": "firstapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.1",
"npm": "^8.15.0"
}
}
I copied your code into my editor and didn't face any errors. Double check the directory you are working from in your terminal and then try updating express
first, check that express is installed or not
if not run the following command
npm i express
also, check that you are using the latest version of the node
if all ok then run
node index.js
is still an issue not fixed submit your folder structure and package.json so I can give you further assistance
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.