Answer the question
In order to leave comments, you need to log in
Require() in Node.js (exports or this)?
The article Understanding require() in Node.js shows the difference between exports and this .
This example
var PI = 3.14
this.area = function ( r ) {
return PI * r * r
}
this.circumference = function ( r ) {
return 2 * PI * r
}
var t=new require('./test')
(function (exports, require, module, __filename, __dirname) { const {
sudo apt-get purge node
sudo apt-get purge nodejs
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get update && sudo apt-get install -y node
sudo apt-get update && sudo apt-get install -y nodejs
Answer the question
In order to leave comments, you need to log in
You install some kind of fossil node 0.10
Read the source https://github.com/nodesource/distributions#debinstall and you only need to install nodejs
Well, or even use some kind of nvm .
The 2011 article is somehow not very good either, and it is all described by simple identities:
// в контексте модулей
this === exports // true
this === module.exports // true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question