Search code examples
node.jsember.jsnpmember-cli

Creating an Ember CLI in-app/in-repo Addon: how to install npm dependencies?


I have an "in-app" (or "in-repo") Ember addon in my project's lib directory. The addon has its own dependencies listed in its own package.json file. My project's top level package.json specifies the addon path:

  "ember-addon": {
    "paths": [
      "lib/my-addon-here"
    ]
  }

However, when I run npm install at the project root, it does not install the addon's dependencies.

Is there a way to configure this so that the addon's dependencies are installed when running npm install from the project root?


Solution

  • You don't.

    List dependencies in the host app's package.json.

    The in-repo addon's package.json is used only for reading some configuration from it. For example, this is how ember-cli-deploy determines which addons are deploy plugins.

    If you do want to separate dependencies, then create a regular addon. Use npm link in the addon and then npm link <addon-name> in the host app to simplify addon development.

    From @jelhan: For linting to work properly, Node dependencies that you require() in the addon should be listed in the addon's package.json as well. See for more details.