DIY your own npm package.
purpose
test npm package DIY.
step by step
-
create description file of npm package.
You can use npm init to create the package.json.
It will prompt you for values for the package.json fields.
The two required fields are name and version. like this:mkdir mypkg; cd mypkg; npm init
-
edit main js file 'index.js'
exports.test = function() { console.log("This is a message from the mypkg package"); }
-
edit test script (optional)
console.log('execute test script.')
and then, you can make test: as follow:
npm test
that's all about DIY your own npm moudule. 😃
usage
-
Make a new directory outside of your project and cd into it,
edit package.json , add dependency of your own package:cd ../; mkdir mytest; cd mytest;
and then, edit package.json like this:
"name": "my_test", "dependencies": { "mypkg": "file:../mypkg" } }
-
execute:
npm install
you can see output as follow:
my_test@ /Users/changxun/Code/testdir └── mypkg@1.0.0 npm WARN xun_test@ No description npm WARN xun_test@ No repository field. npm WARN xun_test@ No license field.
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
· 从零开始开发一个 MCP Server!
· ThreeJs-16智慧城市项目(重磅以及未来发展ai)
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
· Ai满嘴顺口溜,想考研?浪费我几个小时
· Browser-use 详细介绍&使用文档