博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
01.【Node.js Module】 Create a Node.js Module and Use it Locally
阅读量:6159 次
发布时间:2019-06-21

本文共 1210 字,大约阅读时间需要 4 分钟。

I'm practicing my English ability lately in order to be recruited by a foreign company for my next job-hopping,if there is anything that I did't express precisely, please pardon me.

How to Create a Node.js Module

1. Create a new directory and enter it.

e.g:/d/sayHelloWorld

2. Init your Node.js module.

You will set name, descrption, entry point and etcetera for your Node.js module.

When you are done, there will be a new file in your directory called "package.json", which contains all of the information you just set.
entry point: your entry file of your Node.js module.
test command: the command that you need to execute your unit test.
npm init

3. Create your entry point.

e.g:/d/sayHelloWorld/index.js

module.exports = {    say() {    console.log('Hello World!')   }}

How to use your Node.js Module Locally

1. Create a new directory and enter it.

2. Install the Node.js module that you created before.

npm install [Node.js Module Path]   // e.g: npm install ../sayHelloWorld/

3. Enter into the Node shell interface, and test if your Node.js Module is available to use.

nodevar test = require([Node.js Module Name]) // e.g: var test = require('sayhelloworld')test.say() // write out 'Hello World'

Related:

转载地址:http://wisfa.baihongyu.com/

你可能感兴趣的文章
Character中的奇葩
查看>>
c++书籍推荐
查看>>
Exception在语义上的处理。在系统中的意义。
查看>>
认知的构成
查看>>
利用事件进行窗体间传值
查看>>
《HTML5秘籍:the missing manual》读书笔记
查看>>
Red hat linux 下装mysql5问题总结
查看>>
源码编译LAMP平台
查看>>
Hibernate各种主键生成策略与配置详解
查看>>
我们离DevOps有多远--持续集成思想的延伸
查看>>
gist
查看>>
我的友情链接
查看>>
git show HEAD^num和个git show HEAD~num的区别
查看>>
[翻译中] 使用Wayland替代X, 大幅提高图形速度
查看>>
warning delete ·· (prettier/prettier)
查看>>
hdu1065
查看>>
httpd协议概述
查看>>
我的友情链接
查看>>
Zabbix 3.0 部署监控 [三]
查看>>
Mysql命令行导入sql数据
查看>>