Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install npm dependencies of composer dependency #28

Closed
btamas opened this issue May 15, 2019 · 1 comment
Closed

Install npm dependencies of composer dependency #28

btamas opened this issue May 15, 2019 · 1 comment
Labels

Comments

@btamas
Copy link

btamas commented May 15, 2019

I'm working on a project that has multiple composer dependencies. One of these dependencies has a frontend dependency. When I run composer install on dependency directory, foxy works like a charm. When I run composer install in the project directory, it installs extension as a composer dependency, but npm install runs in the project directory instead of the dependency directory, so package.json file is not found and npm dependencies are not installed. And an empty package.json file appears in the project directory. Is it a not supported feature or my configuration is wrong?

Extension:

composer.json

...
"type": "extension",
"require": {
    "foxy/foxy": "^1.0.0"
},
"config": {
    "foxy": {
        "manager": "npm",
        "manager-options": "--prefix views"
    }
},
...

views/package.json
// some npm dependency

Project

composer.json

...
"require": {
    "extension": "^1.0.0"
}
...
@francoispluchino
Copy link
Member

The installation of NPM/Yarn dependencies is always in the node_modules folder (by default) of the project folder. It is normal that it is not in the folder of the PHP extension. This is the behavior of NPM and Yarn, and all package managers, because ultimately, these are the dependencies of the project. This avoids duplicate libraries, allows to analyze the dependency tree, check conflicts, etc... and therefore to solve all the dependencies of the project. In addition, if you install the dependencies in the PHP library folder, this will be removed when the PHP library is updated. For more information on how Foxy works, feel free to read the FAQ How does the plugin work?.

You get an empty package.json file because Foxy detects that your composer.json file requires Foxy, but it can not find the package.json file from the PHP library. From what I understand, the package.json file is in the views folder, however, it must be placed in the same folder as the composer.json file.

Regarding your configuration, the config.foxy section is used only for the composer.json file of the project, and not the one of the library (see the doc of config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants