dep: a little Node.js dependency installer

Daijiro Wachi
5 min readAug 25, 2017

--

What’s the bare minimum features of npm?

I’ve been building a little Node.js dependency installer called “dep” which is like a small npm. I will introduce about the dep and tell you my thought.

https://github.com/depjs/dep

You might doubt dep as reinventing the wheel of npm, but this wheel is much smaller than npm.

Rethink npm

As a contributor, I’ve seen how the npm command is growing for couple of years. We’ve added a lot of features requested by users, and that increased the size of the code base. The more we added the features, the more complexity is gained and I’m feeling that it makes bug-fix harder.

When I also see $npm --help, it asks me a question.

How many kinds of npm sub commands do I often use on daily basis?

npm’s sub command list

In fact, it was already said that npm is very complex in 2015.

While the complexity of npm’s git dependency handling is nearly fractal (because npm is very complex, and git is even more complex),

Recently, people gradually came to find out the bare minimum functions of npm to have a simple one.

Of course, there is no right answer for what is the minimum because of the number of the use cases.

The greatest common factor is always depends on the given context.

In this case, the context is the target user and I found out an answer to this problem on my own way.

The end user

I caught up with the idea of a module end-user. It is not a module author, nor a module user, but just a module end-user.

The end user is who makes a software with the modules and doesn’t make their own module to publish.

What they do is:

  • Install dependencies defined in package.json
  • Deploy an app to production with locked dependencies
  • Run test/build/release scripts defined in package.json

It turns out that the only features we should support for the end-user are install, lock, and run.

This idea made the scope clearer.

Hello dep!

So I made dep: https://github.com/depjs/dep

The dep has only the following three features:

  • Install the dependencies defined in a local package.json.
  • [WIP]Lock the dependencies installed in a local node_modules.
  • Run an arbitrary command from scripts in a local package.json.

I tried to make them same with npm as much as possible, so I will skip the basic command description this time. See the README.md for more info.

Bethink npm

In rethinking npm, I ponder of everything from zero since it’s the right timing. For example, the compatibility with npm is very important as I tried. The interface in the command line should be the same because of like what @bitandbang said.

https://twitter.com/bitandbang/status/891002889946095616

Then I made the same interface for most of the commands and options that should be supported in dep, but there are some slightly different implementations internally.

dep ❤️ dat

This is a totally experimental feature and can be changed at any time as like Node.js ‘s experimental feature.

$ dep install dat link

dep supports the dat protocol as a dependency resource.

{
"name": "an-app",
"description": "an example app",
"dependencies": {
"emoji-cli": "dat://7fdbb7b4ea8be0e5d9c1469aa4056377a092d8787b6e3452faf0ce8390098d02"
}
}

Although npm registry is great, since dat registry is running with completely different concepts and technologies, simply I was interested in supporting that. For more info about the dat project, visit their website:

dep 💔 local cache

Speed and local disk capacity are a trade-off, but I’d like to take the both.

image: my mac has little free space

I am thinking about designing to create a cache in a place like a proxy server instead of directly creating it in the local disc. Because of that, dep does not make cache files in a local disc for now.

dep ❤️ Windows

The goal is to keep the size small and to keep the state where bugs can be easily repaired easily. I’d say the following badges are what dep is caring.

Badges

The number of features and the time of tests are proportional.

To recap

Just as a rich function is a value, smallness is also a value. Based on the ease of bug fix, I continue keeping dep simple. It would be great if the case comes to being able to choose a package manager to bundle into the Node.js core.

Use it and drop your thoughts on the repo :3
Also, I’d love to give active contributors the r/w permission.

https://github.com/watilde/dep

dep ️and npm

Last but not least, I still like npm for sure and that’s one of the reasons why I’m trying to have the compatibilities with npm.

Many thanks to @ReBeccaOrg and @maybekatz for all of your advices!

https://twitter.com/ReBeccaOrg/status/888861923927707648
https://twitter.com/maybekatz/status/893375699133661184

Have a good Friday👋

xoxo,
@watilde

--

--