Node.js v10.6.0 Documentationnodejs.org/api/modules.html 在Node.js模块系统,每一个文件都被当做一个独立的模块。例如,一个名为foo.js的文件: const circle = require('./circle.js'); console.log(`The area of a circle of radius 4 is ${circle.area(4)}`);...
如果给require()传递的 module 名称不是一个 core module, 并且没有以'/','../','./'作为开始, 那么Node.js 会尝试从node_modules目录下面查找所需要的module。 举例来说:有一个位于 ''/home/ry/projects/foo.js'' 调用require('bar.js'), node.js 回按照下面的方式顺序查找bar.js /home/ry/project...
For the last few years, Node.js has been working to support running ECMAScript modules (ESM). This has been a very difficult feature to support, since the foundation of the Node.js ecosystem is built on a different module system called CommonJS (CJS). Interoperating between the two module...
Accessing Core Node.js Modules Assignment of the _ (underscore) variable Custom Evaluation Functions Recoverable Errors Customizing REPL Output Class: REPLServer Event: 'exit' Event: 'reset' replServer.defineCommand(keyword, cmd) replServer.displayPrompt([preserveCursor]) repl.start([options]) The...
Node.js modules are a type ofpackagethat can be published to npm. Overview Create apackage.jsonfile Create the file that will be loaded when your module is required by another application Test your module package.json To create apackage.jsonfile, on the command line, in the root directory ...
Command-line options Console Corepack Crypto Debugger Deprecated APIs Diagnostics Channel DNS Domain Errors Events File system Globals HTTP HTTP/2 HTTPS Inspector Internationalization Modules: CommonJS modules Modules: ECMAScript modules Modules:node:moduleAPI ...
2. Node.js API —— Timers(定时器)(4910) 3. Node.js API —— process(进程)(1147) 4. Node.js API —— Modules(模块)(812) 5. Node.js API —— util(工具)(726) 评论排行榜 1. Node.js API —— About this Documentation(关于本文档)(2) 最新...
➜ node arguments.js { '0': {}, '1': { [Function: require] resolve: [Function: resolve], main: Module { id: '.', exports: {}, parent: null, filename: '/Users/sunhengzhe/Documents/learn/node/modules/demos/arguments.js', ...
Introduces design patterns and well-established solutions to the Node.js landscape. Everything you need.. Build robust, powerful, and scalable server-side applications and stop reinventing the wheel. Modularity Streamline upkeep by organizing applications into self-contained modules. ...
默认状况下,咱们在执行npm install -g 模块时,下载了一个全局包,这个包的默认存放路径C:\Users\xxx\AppData\Roaming\npm\node_modules下,时间长了肯定会占用C盘的资源,所以需要我们在node.js的安装目录下创建两个文件夹:node_global和node_cache 然后执行这两个命令(改成自己的路径): npm config set prefix "...