T
T
Tomskiy2022-01-18 16:15:48
JavaScript
Tomskiy, 2022-01-18 16:15:48

Why does Node js throw a ReferenceError: recuire is not defined error when a module is connected?

The app.js and config.js files are created in the same place.
config.js contains
module.exports = {
a : 3,
d : 6
};
app.js contains
const config = recuire('./config');

console log(config);
I run the app.js file in the VS Code terminal, it gives an error in the terminal:
ReferenceError: recuire is not defined
at Object. (C:\Users\Dmitry\app.js:1:16)
Node js version v13.14.0.
Windows 7.
Tell me what is the reason for this error.
Screenshot
61e6bd13580c1193320366.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rag'n' Code Man, 2022-01-18
@iDmitriyWinX

recuire()There is no such functionrequire()

Z
Zeaxyz, 2022-01-18
@Zeaxyz

If you want to import code from other files, it's better to use modules and import. To do this, you need to add the property "type": "module" to package.json and to connect modules, both your own and, for example, default ones, use import {funcName} from 'path';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question