1
I installed the framework express in my root folder with all projects on Node, so it was easy to import the modules in all projects. But when I try to start a local server, with the following scope:
const reference = require("../node_modules/express");
const app = express();
app.listen(8081);
I always get the following message when trying to run the server through the terminal:
C:\Users\Usuário\Desktop\Node\serverExpress>node index.js
C:\Users\Usuário\Desktop\Node\serverExpress\index.js:9
const app = express();
^
ReferenceError: express is not defined
at Object.<anonymous> (C:\Users\Usuário\Desktop\Node\serverExpress\index.js:9:13)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
As far as I know, the express function on line two comes along with the module import. What may be wrong?
which association between app and express() I’m not seeing, vc is assigning to app a value that it does not find.
– André Martins
const express = require('express');
const app = express();
– Augusto Vasques