id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
Providers/const_108_0.txt
// var declarations are not scoped to blocks so this throws an error var MY_FAV = 20; // SyntaxError: Identifier 'MY_FAV' has already been declared }
Providers/const_60_0.txt
Search MDN Clear search input Search
Providers/const_142_0.txt
* [ Product help ](https://support.mozilla.org/products/mdn-plus) * [ Report an issue ](/en-US/docs/MDN/Community/Issues)
Providers/requiringmodulesinno_87_0.txt
Let’s also talk about the ` loaded ` attribute on every module. So far, every time we printed a module object, we saw a ` loaded ` attribute on that object with a value of ` false ` .
Providers/const_134_0.txt
This page was last modified on Sep 12, 2023 by [ MDN contributors ](/en- US/docs/Web/JavaScript/Reference/Statements/const/contributors.txt) .
Providers/requiringmodulesinno_29_0.txt
The paths list is basically a list of node_modules directories under every directory from the current directory to the root directory. It also includes a few legacy directories whose use is not recommended.
Providers/requiringmodulesinno_62_0.txt
~/learn-node $ mkdir lib ~/learn-node $ echo "console.log('In util', module);" > lib/util.js
Providers/howtousethejavascrip_33_0.txt
In this article, you have learned what the require() function does, how it works, and when you can use it in Node.js.
Providers/Providers_47_1.txt
](/v6/api/providers/#Provider#Provider-getCode) and [ state trie storage ](/v6/api/providers/#Provider#Provider-getStorage) . Simulating execution can be used to [ call ](/v6/api/providers/#Provider#Provider-call) , [ estimate gas ](/v6/api/providers/#Provider#Provider-estimateGas) and [ get transaction results ]...
Providers/indexjs_24_0.txt
Search
Providers/indexjs_81_0.txt
## Footer
Providers/requiringmodulesinno_128_0.txt
Looking at the functions for each extension, you can clearly see what Node will do with each. It uses ` module._compile ` for ` .js ` files, ` JSON.parse ` for ` .json ` files, and ` process.dlopen ` for ` .node ` files.
Providers/howtousethejavascrip_14_0.txt
In the browser, JavaScript module execution depends upon ` import ` and ` export ` statements. These statements load and export ES modules, respectively. This is the standard and official way to reuse modules in JavaScript, and it’s what most web browsers natively support.
Providers/Providers_22_0.txt
METHODS io/ethers.js/blob/main/src.ts/providers/plugins-network.ts#L221) feeDataNetworkPlugin . getFeeData ( provider : [ Provider ](/v6/api/providers/#Provider) ) ⇒ Promise< [ FeeData ](/v6/api/providers/#FeeData) > Resolves to the fee data.
Providers/const_68_0.txt
## In this article
Providers/requiringmodulesinno_139_0.txt
That ` answer ` variable will be globally available in all scripts after the script that defined it.
Providers/requiringmodulesinno_168_0.txt
Say, for example, that we have this simple ` printInFrame ` function in ` print-in-frame.js ` :
Providers/requiringmodulesinno_232_0.txt
## Mobile App
Providers/requiringmodulesinno_102_0.txt
require('./module2');
Providers/const_105_0.txt
It's important to note the nature of block scoping.
Providers/requiringmodulesinno_11_0.txt
Requiring a module in Node isn’t that complicated of a concept.
Providers/requiringmodulesinno_42_0.txt
#### Requiring a folder
Providers/Providers_54_0.txt
METHODS io/ethers.js/blob/main/src.ts/providers/provider.ts#L1139) transactionReceipt . confirmations ( ) ⇒ Promise< number > Resolves to the number of confirmations this transaction has. io/ethers.js/blob/main/src.ts/providers/provider.ts#L1111) transactionReceipt . getBlock ( ) ⇒ Promise< [ Block ](/v6/...
Providers/const_133_0.txt
[ Learn how to contribute ](https://github.com/mdn/content/blob/main/CONTRIBUTING.md "This will take you to our contribution guidelines on GitHub.") .
Providers/howtousethejavascrip_23_0.txt
// utils.js const getFullName = (firstname, lastName) => { return `My fullname is ${firstname} ${lastName}`; }; module.exports = getFullName;
Providers/Providers_2_0.txt
class Block inherits from [ BlockParams ](/v6/api/providers/formatting/#BlockParams) A Block represents the data associated with a full block on Ethereum.
Providers/indexjs_25_0.txt
Clear
Providers/requiringmodulesinno_1_0.txt
[ ![freeCodeCamp.org](https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg) ](https://www.freecodecamp.org/news/)
Providers/requiringmodulesinno_117_0.txt
console.log(`Server will run at http://${host}:${port}`);
Providers/requiringmodulesinno_61_0.txt
Create a ` lib/util.js ` file and add a ` console.log ` line there to identify it. Also, ` console.log ` the ` module ` object itself:
Providers/requiringmodulesinno_146_0.txt
You can see this wrapping in action if you run a script with a problem on its first line:
Providers/requiringmodulesinno_221_0.txt
Read [ more posts ](/news/author/samerbuna/) .
Providers/const_125_0.txt
Specification --- [ ECMAScript Language Specification # sec-let-and-const-declarations ](https://tc39.es/ecma262/multipage/ecmascript-language-statements-and- declarations.html#sec-let-and-const-declarations)
Providers/const_128_0.txt
## See also
Providers/requiringmodulesinno_91_0.txt
The index.js module object is now loaded! Module { id: '.', exports: [Function], parent: null, filename: '/Users/samer/learn-node/index.js', loaded: true, children: [ Module { id: '/Users/samer/learn-node/lib/util.js', exports: [Object], parent: [Circular], filename: '/Users/samer/learn-node/lib/util.js', loaded: true,...
Providers/requiringmodulesinno_34_0.txt
~/learn-node $ echo "console.log('I am not lost');" > node_modules/find-me.js
Providers/howtousethejavascrip_56_0.txt
* [ ![Download on the App Store](https://cdn.freecodecamp.org/platform/universal/apple-store-badge.svg) ](https://apps.apple.com/us/app/freecodecamp/id6446908151?itsct=apps_box_link&itscg=30200) * [ ![Get it on Google Play](https://cdn.freecodecamp.org/platform/universal/google-play-badge.svg) ](https://play.google.com...
Providers/requiringmodulesinno_115_0.txt
We can require it directly like this:
Providers/const_56_0.txt
* [ FAQ
Providers/const_71_0.txt
11. [ BigInt64Array ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array) 12. [ BigUint64Array ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array) 13. [ Boolean ](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) 14. [ DataView ](/en-US/docs/Web/JavaScript/Reference/Global_Ob...
Providers/requiringmodulesinno_36_0.txt
If another ` find-me.js ` file existed in any of the other paths, for example, if we have a ` node_modules ` directory under the home directory and we have a different ` find-me.js ` file in there:
Providers/indexjs_40_0.txt
{{ message }}
Providers/Providers_11_0.txt
class EnsPlugin inherits from [ NetworkPlugin ](/v6/api/providers/#NetworkPlugin) An EnsPlugin allows a [ Network ](/v6/api/providers/#Network) to specify the ENS Registry Contract address and the target network to use when using that contract. Various testnets have their own instance of the contract to use, bu...
Providers/Providers_65_0.txt
class Network A Network provides access to a chain's properties and allows for plug-ins to extend functionality.
Providers/Providers_16_0.txt
PROPERTIES The gas price for legacy networks. The maximum fee to pay per gas. The base fee per gas is defined by the network and based on congestion, increasing the cost during times of heavy load and lowering when less busy. The actual fee per gas will be the base fee for the block and the priority fee, up to th...
Providers/const_120_0.txt
### Declaration with destructuring
Providers/requiringmodulesinno_174_0.txt
~/learn-node $ node print-in-frame 8 Hello
Providers/const_63_0.txt
1. [ References ](/en-US/docs/Web) 2. [ JavaScript ](/en-US/docs/Web/JavaScript) 3. [ Reference ](/en-US/docs/Web/JavaScript/Reference) 4. [ Statements and declarations ](/en-US/docs/Web/JavaScript/Reference/Statements) 5. [ const ](/en-US/docs/Web/JavaScript/Reference/Statements/const)
Providers/Providers_12_0.txt
PROPERTIES io/ethers.js/blob/main/src.ts/providers/plugins-network.ts#L168) ensPlugin . address ⇒ string read-only The ENS Registrty Contract address. io/ethers.js/blob/main/src.ts/providers/plugins-network.ts#L173) ensPlugin . targetNetwork ⇒ number read-only The chain ID that the ENS contract lives on.
Providers/indexjs_4_0.txt
[ Sign in ](/login?return_to=https%3A%2F%2Fgithub.com%2FSuhailTechInfo%2FSuhail- Md%2Fblob%2Fmain%2Findex.js)
Providers/Providers_58_1.txt
bsocket-like object.
Providers/requiringmodulesinno_185_0.txt
const printInFrame = (size, header) => { console.log('*'.repeat(size)); console.log(header); console.log('*'.repeat(size)); };
Providers/howtousethejavascrip_54_0.txt
* [ Date Formatting in JS ](https://www.freecodecamp.org/news/how-to-format-a-date-with-javascript-date-formatting-in-js/) * [ Java Iterator Hashmap ](https://www.freecodecamp.org/news/java-iterator-hashmap-how-to-iterate-through-a-hashmap-with-a-loop/) * [ Cancel a Merge in Git ](https://www.freecodecamp.org/news/git-...
Providers/indexjs_28_0.txt
We read every piece of feedback, and take your input very seriously.
Providers/requiringmodulesinno_218_0.txt
ADVERTISEMENT
Providers/indexjs_29_0.txt
Include my email address so I can be contacted
Providers/indexjs_71_0.txt
Debug . info ( `Suhail ${ VERSION } ` )
Providers/requiringmodulesinno_173_0.txt
1. From the command line directly like this:
Providers/Providers_67_0.txt
CREATING INSTANCES io/ethers.js/blob/main/src.ts/providers/network.ts#L74) new Network ( name : string , chainId : [ BigNumberish ](/v6/api/utils/#BigNumberish) ) Creates a new Network for name and chainId . io/ethers.js/blob/main/src.ts/providers/network.ts#L223) Network . from ( network ?: [ Net...
Providers/requiringmodulesinno_127_0.txt
![D3NuN7cetXAjYpHfqBGribFo-ex0fj-AvuDA](https://cdn- media-1.freecodecamp.org/images/D3NuN7cetXAjYpHfqBGribFo-ex0fj-AvuDA)
Providers/Providers_43_0.txt
class NonceManager inherits from [ AbstractSigner ](/v6/api/providers/abstract- signer/#AbstractSigner) , [ Signer ](/v6/api/providers/#Signer) A NonceManager wraps another [ Signer ](/v6/api/providers/#Signer) and automatically manages the nonce, ensuring serialized and sequential nonces are used during transa...
Providers/const_17_0.txt
* [ Web APIs
Providers/Providers_4_0.txt
CREATING INSTANCES io/ethers.js/blob/main/src.ts/providers/provider.ts#L527) new Block ( block : [ BlockParams ](/v6/api/providers/formatting/#BlockParams) , provider : [ Provider ](/v6/api/providers/#Provider) ) Create a new Block object. This should generally not be necessary as the unless implementing a l...
Providers/const_103_0.txt
// Redeclaring a constant throws an error const MY_FAV = 20; // SyntaxError: Identifier 'MY_FAV' has already been declared var MY_FAV = 20; // SyntaxError: Identifier 'MY_FAV' has already been declared let MY_FAV = 20; // SyntaxError: Identifier 'MY_FAV' has already been declared
Providers/Providers_35_0.txt
PROPERTIES io/ethers.js/blob/main/src.ts/providers/provider.ts#L771) log . address ⇒ string read-only The address of the contract that emitted this log. io/ethers.js/blob/main/src.ts/providers/provider.ts#L750) log . blockHash ⇒ string read-only The block hash of the block this log occurred in. Use the [ l...
Providers/requiringmodulesinno_214_0.txt
ADVERTISEMENT
Providers/Providers_34_0.txt
class Log inherits from [ LogParams ](/v6/api/providers/formatting/#LogParams) A Log in Ethereum represents an event that has been included in a transaction using the LOG* opcodes, which are most commonly used by Solidity's emit for announcing events.
Providers/requiringmodulesinno_147_0.txt
~/learn-node $ echo "euaohseu" > bad.js
Providers/const_92_0.txt
An initializer for a constant is required. You must specify its value in the same declaration. (This makes sense, given that it can't be changed later.)
Providers/requiringmodulesinno_106_0.txt
When we run ` module1.js ` we see the following:
Providers/const_121_0.txt
The left-hand side of each ` = ` can also be a binding pattern. This allows creating multiple variables at once.
Providers/const_4_0.txt
](/en-US/docs/Web)
Providers/indexjs_17_0.txt
* [ GitHub Sponsors Fund open source developers ](https://github.com/sponsors)
Providers/const_130_0.txt
## Help improve MDN
Providers/requiringmodulesinno_181_0.txt
This is where we can use this simple if statement:
Providers/const_90_0.txt
* ` const ` declarations are scoped to blocks as well as functions. * ` const ` declarations can only be accessed after the place of declaration is reached (see [ temporal dead zone ](/en-US/docs/Web/JavaScript/Reference/Statements/let#temporal_dead_zone_tdz) ). For this reason, ` const ` declarations are commonly rega...
Providers/howtousethejavascrip_42_0.txt
* * *
Providers/requiringmodulesinno_138_0.txt
var answer = 42;
Providers/requiringmodulesinno_223_0.txt
If you read this far, thank the author to show them you care. Say Thanks
Providers/const_62_0.txt
* [ Log in ](/users/fxa/login/authenticate/?next=%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FStatements%2Fconst) * [ Sign up for free ](/users/fxa/login/authenticate/?next=%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FStatements%2Fconst)
Providers/indexjs_58_0.txt
main
Providers/const_152_0.txt
Non-standard
Providers/const_73_0.txt
40. [ Less than or equal (<=) ](/en-US/docs/Web/JavaScript/Reference/Operators/Less_than_or_equal) 41. [ Logical AND (&&) ](/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND) 42. [ Logical AND assignment (&&=) ](/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND_assignment) 43. [ Logical NOT (!) ](/en-...
Providers/requiringmodulesinno_4_0.txt
# Requiring modules in Node.js: Everything you need to know
Providers/indexjs_62_0.txt
Top
Providers/indexjs_21_0.txt
* [ Pricing ](https://github.com/pricing)
Providers/requiringmodulesinno_30_0.txt
If Node can’t find ` find-me.js ` in any of these paths, it will throw a “cannot find module error.”
Providers/howtousethejavascrip_11_0.txt
For a long time, the CommonJS module system has been the default module system within the Node.js ecosystem. But a new module system was introduced in [ Node.js v8.5.0 ](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V8.md#8.5.0) , which is the ES module system.
Providers/Providers_31_0.txt
class IpcSocketProvider inherits from [ SocketProvider ](/v6/api/providers/abstract- provider/#SocketProvider) , [ JsonRpcApiProvider ](/v6/api/providers/jsonrpc/#JsonRpcApiProvider) An IpcSocketProvider connects over an IPC socket on the host which provides fast access to the node, but requires the node and the ...
Providers/indexjs_15_0.txt
* [ Learning Pathways ](https://resources.github.com/learn/pathways) * [ White papers, Ebooks, Webinars ](https://resources.github.com) * [ Customer Stories ](https://github.com/customer-stories) * [ Partners ](https://partner.github.com)
Providers/requiringmodulesinno_132_0.txt
exports.id = 42; // This is ok.
Providers/howtousethejavascrip_26_0.txt
The module is located within a local file in the above code, which is why the local address is referenced using the file name.
Providers/indexjs_64_0.txt
* Code
Providers/requiringmodulesinno_16_0.txt
Let me first create a directory to host all the examples using my terminal:
Providers/requiringmodulesinno_126_0.txt
We can actually see the support of the three extensions by looking at ` require.extensions ` .
Providers/requiringmodulesinno_86_0.txt
UTIL: { id: 'lib/util' }
Providers/requiringmodulesinno_189_0.txt
Caching is important to understand. Let me use a simple example to demonstrate it.
Providers/indexjs_22_0.txt
Search or jump to...
Providers/const_18_0.txt
Interfaces for building web applications
Providers/const_144_0.txt
* [ MDN Community ](/en-US/community) * [ MDN Forum ](https://discourse.mozilla.org/c/mdn/236) * [ MDN Chat ](/discord)