简体   繁体   English

在app-in-appo中创建Ember CLI Addon:如何安装npm依赖项?

[英]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. 我在项目的lib目录中有一个“应用程序内”(或“in-repo”)Ember插件。 The addon has its own dependencies listed in its own package.json file. 插件在其自己的package.json文件中列出了自己的依赖项。 My project's top level package.json specifies the addon path: 我的项目的顶级package.json指定了插件路径:

  "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. 但是,当我在项目根目录运行npm install时,它不会安装插件的依赖项。

Is there a way to configure this so that the addon's dependencies are installed when running npm install from the project root? 有没有办法配置它,以便在从项目根目录运行npm installnpm install插件的依赖项?

You don't. 你没有。

List dependencies in the host app's package.json . 列出主机应用程序的package.json中的依赖项。

The in-repo addon's package.json is used only for reading some configuration from it. in-repo addon的package.json仅用于从中读取一些配置。 For example, this is how ember-cli-deploy determines which addons are deploy plugins. 例如,这就是ember-cli-deploy确定哪些插件是部署插件的方式。

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. 在插件中使用npm link ,然后在主机应用程序中使用npm link npm link <addon-name>来简化插件开发。

UPD: For linting to work properly, Node dependencies that you require() in the addon should be listed in the addon's package.json as well. UPD:为了使linting正常工作,插件中你require()节点依赖项require()应该在addon的package.json列出。 See (and upvote) @jelhan's comment for more details. 有关更多详细信息,请参阅(和upvote)@ jelhan的评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM