Skip to content

Instantly share code, notes, and snippets.

@robatron
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robatron/099d908405f2c356380c to your computer and use it in GitHub Desktop.
Save robatron/099d908405f2c356380c to your computer and use it in GitHub Desktop.
Nested Node Package Development and Integration Testing

Nested Node Package Development and Integration Testing

How to actively develop and integration test a Node package within another Node package

Ideally, you'll want to develop your Node package in a self-contained way, thorugh unit testing and examples, independent from other packages. Sometimes, however, you'll want to develop your Node package within another package for integration testing purposes.

  1. From your package directory, run npm link. This will create a globally-installed symlink to your package.

     cd ~/code/my-package
     npm link
    
  2. From the desired parent package directory, run npm link $PACKAGE_NAME where $PACKAGE_NAME is the name of your package. This will create a symlink from the parent package's node_modules directory to the global symlink of your package.

     cd ~/code/parent-package
     npm link my-package
    
  3. Develop and integration test! Now, any change you make to your package will be seen from the parent package.

  4. Commit and publish your changes when you're finished to give others access to your package updates.

Resources

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