Depending on Other Packages


How do I depend on other packages? i.e. I am making a package and in that package I want to extend the Autocomplete package to use the Autocomplete class, a lot of work has been done that I don’t want to duplicate.

How to add dependencies on other packages?
Recommended approach to logging?
How to make a package install other packages
Install package in other folder
Import package inside theme
Can I create a distribution of Atom?


This looks like it’s talking about binary resouces like gifs. I’m trying to require the Autocomplete view.
Autocomplete = require ‘/path/to/autocomplete-view’


There is not an official API to require files from other packages, but of course you can brute force it since you can find the path to the package using atom.packages.resolvePackagePath('autocomplete') and then just require paths from there directly using the built-in require method.

For this case it seems like adding an API to the autocomplete package is the right approach and that API will be available via the atom.packages global which allows packages to access one another exported APIs.

Perhaps you could open an issue on the autocomplete repo and we can get it done there?


Not ideal, but this also works

"dependencies": {
  "autocomplete": "git+"


I think there needs to be an official mechanism. What made e.g. Emacs and Eclipse so extendable was the possibility to extend existing packages by using hooks provided by them


what @AbeEstrada said is correct… I mean all this stuff is just commonjs so we just need to add the APIs to the module.exports object right? do we need to make it more complicated then that?


Thank you, @AbeEstrada

But this does not seem to work.

For this package that compares two files and show the diff, I have added the language-diff package as a dependency as suggested:

  "dependencies": {
    "diff": "^1.0.8",
    "lodash": "^2.4.1",
    "temp": "^0.7.0",
    "language-diff": "git+"

Is there any other way to enforce the installation of the language-diff package for people installing the compare-files one?



I cloned then ran apm update and it downloaded language-diff as dependencie not as a package.

Not sure if you can force a user to install a package or do it programmatically, but at least you can verify if the package is loaded and active


Thanks @AbeEstrada
It was my mistake - I misinterpreted this discussion a little.
Probably because my need was for another existing package to be (probably automatically) installed when my package is getting installed.


So it’s clear that there isn’t currently anyway to add a dependency on another atom package (which is very distinct from requiring a node package which is supported). But it is possible to detect whether that package is installed.

Assuming that a feature for this isn’t coming any time soon, does anyone have any tips for how to handle this case? Do you prevent activation of your package and display a dialog prompting the user to install the package first? Do you do this ever time atom loads? What do you put in the message? Do you degrade your package so that features built on the other package aren’t enabled?

Seems like there are a bunch of options and would love to hear what people have tried and the feedback from their user base on it …


@ralphcallaway @JAStanton

I have created an npm module that allows an Atom package to depend on others.

It’s a work in progress, so all criticisms/improvements are welcome.


This is great. Your timing is bad though. I had to implement this in a package last week. My package doesn’t install the dependency so I may switch.


Kevin, do you know if the Atom team is planning on adding support for depending on other Atom packages? Is the “brute force” way what you would recommend generally for now?

I’m specifically looking to modify the UI of the tree-view sidebar, which comes in the “tree-view” package, which is bundled together with Atom by default. Upon activating, the package creates the “treeView” view object, and it would be convenient to grab that reference as opposed to walking the DOM to find it.


Take a look at the ServiceHub class and its documentation. It describes a method whereby packages can provide APIs to and consume APIs from each other. I think it is a pretty cool system.

Specifying package dependencies

It feels like we need a mechanism to depend on specific Atom packages. I.e. in package.json:

  "name": "my-package",
  "main": "./lib/my-package",
  "version": "0.0.0",
  "description": "A short description of your package",
  "activationCommands": {
    "atom-workspace": "my-package:toggle"
  "repository": "",
  "license": "MIT",
  "engines": {
    "atom": ">0.50.0"
  "dependencies": {
  "atomPackageDependencies": {
    "autocomplete-plus": ">=0.22.12"

i.e. I’m proposing extending the package.json schema to include:

  "atomPackageDependencies": {
    "autocomplete-plus": ">=0.22.12"

This would give apm and PackageManager the metadata required to install required packages (when specified). It could also be used as a hint during package activation on startup.

/cc @kevinsawicki


check out my npm module package-dependencies quoted above; it does something very similar.

Of course, since it is a separate module it doesn’t extend the schema directly, but can be used as a convenience workaround for now.

Also feel free to take code from it if you are implementing this behaviour into the default atom install, which would be even more convenient than depending on an outside module.

I have also raised issues that I have run into with my package, such as version conflicts, since all packages are stored in the same directory rather than node_module subdirectories in each package.

If nothing else, we can use atom-package-dependencies as a starting point for discussion on this.


@travs Nice! Yes, perhaps we should look into upstreaming this into


:+1: Travs Depending on Other Packages


EDIT UPDATE: this is resolved. But leaving in case someone errors and searches. Great job @travs!

@travs It looked good but I get an error on install:

TypeError: path must be a string
  at TypeError (native)
  at Object.fs.openSync (fs.js:455:18)
  at Object.module.(anonymous function) [as openSync] (c:\Users\basaratsyed\AppData\Local\atom\app-0.172.0\resources\atom\common\lib\asar.js:422:20)
  at Object.fs.readFileSync (fs.js:313:15)
  at Object.fs.readFileSync (c:\Users\basaratsyed\AppData\Local\atom\app-0.172.0\resources\atom\common\lib\asar.js:329:27)
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\index.js:76:30
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\index.js:69:5
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\witwip.js:51:23
  at find (c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\witwip.js:95:12)
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\witwip.js:106:16
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\node_modules\read-package-json\read-json.js:80:40
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\node_modules\read-package-json\read-json.js:128:48
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\node_modules\read-package-json\node_modules\graceful-fs\graceful-fs.js:170:5
  at c:\Users\basaratsyed\.atom\packages\atom-typescript\node_modules\atom-package-dependencies\node_modules\witwip\node_modules\read-package-json\node_modules\graceful-fs\graceful-fs.js:179:5
  at fs.js:295:14
  at Object.oncomplete (fs.js:93:15)

More :

Ok to use grammar.cson for just file assoc…?