Friday, 19 June 2020

[Help] ReferenceError: require is not defined

Noob here. But I know that require is a function for the server-side, so I'm not running the application in the browser.Instead, I type "node app.mjs" in the command prompt to run the application.import { createServer } from 'http';import { readFile } from 'fs'; //import { express } from 'express'; // I couldn't export this way for reason[1] const express = require('express'); // Error here var app = express(); Reason[1]: SyntaxError: The requested module 'express' is expected to be of type CommonJS, which does not support named exports.Enviroment: Windows.

Submitted June 19, 2020 at 07:41AM by vinivelloso_

No comments:

Post a Comment