This package is abandoned and no longer maintained. No replacement package was suggested.

Handle asset dependencies and scripts with npm

Installs: 27 048

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 2

Open Issues: 0


v0.3.0 2017-08-31 04:46 UTC

This package is not auto-updated.

Last update: 2020-08-14 02:43:51 UTC


Build Status Latest Stable Version Latest Unstable Version

The HshnNpmBundle adds support for managing node modules with npm.

Features included:

  • Install node modules in your bundles with one command
  • Invoke npm scripts in your bundles with one command
  • Unit tested


1. Download HshnNpmBundle using composer

$ php composer.phar require hshn/npm-bundle

2. Enable the bundles


// app/AppKernel.php
public function registerBundles()
    $bundles = array(
        // ...
        new Hshn\NpmBundle\HshnNpmBundle(),

3. Configure the HshnNpmBundle

Enable node modules management for your bundles in the config.yml file.

# app/config/config.yml
        YourBundle: ~

3.1. Choose package manager (optional)

You can specify package manager which will be used globally.

# app/config.config.yml

    package_manager: npm # or yarn

Also you can override package manager configuration per bundles.

# app/config.config.yml
    package_manager: npm # use npm globally
        # FooBundle will use npm
        FooBundle: ~
        # BarBundle will use yarn
          package_manager: yarn

4. Installing node modules

Place your package.json in the npm directory, the default value for the npm dir is $yourBundle/Resources/npm.


    "name": "your-bundle-name",
    "dependencies": {
        "lodash": "^4.3.0"

Now run the command app/console hshn:npm:install to install all the dependencies in the npm directory ``$yourBundle/Resources/npm/npde_modules`.

5. Use the installed node modules in your build scripts

Write build scripts you like.

gulp example is here

6. Register your build scripts as a npm script

    "name": "your-bundle-name",
    "dependencies": {
        "lodash": "^4.3.0"
    "scripts": {
        "build": "gulp build"

then you can run the npm script by using following command:

$ php app/console hshn:npm:run build # `npm run build` in every bundles