Skip to content

Instantly share code, notes, and snippets.

@willmendesneto
Created July 13, 2021 03:06
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 willmendesneto/756e1a8360ed629a3939eda658e7690b to your computer and use it in GitHub Desktop.
Save willmendesneto/756e1a8360ed629a3939eda658e7690b to your computer and use it in GitHub Desktop.
Using multiple versions of the same package in a project

How to apply that

  1. Install the packages (old and latest versions) adding a specific name/namespace for the latest one
npm install --save \
  feature-toggle-service@npm:feature-toggle-service@4.0.0 \
  feature-toggle-service-next@npm:feature-toggle-service@6.0.0
  1. Start the code by running npm start
const { isOn, set } = require('feature-toggle-service');
const { isOn: isOnNext, set: setNext } = require('feature-toggle-service-next');
const defaultConfig = { enableFirstSection: true };
set(defaultConfig);
setNext(defaultConfig);
console.log(isOn('enableFirstSection'));
console.log(isOnNext('enableFirstSection', true));
{
"name": "multiple-versions-of-package-in-project",
"version": "1.0.0",
"description": "Using multiple versions of the same package in a project",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "Will Mendes <willmendesneto@gmail.com>",
"license": "ISC",
"dependencies": {
"feature-toggle-service": "npm:feature-toggle-service@^4.0.0",
"feature-toggle-service-next": "npm:feature-toggle-service@^6.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment