Home > other >  How to use a library in ionic application without publishing it to npm
How to use a library in ionic application without publishing it to npm

Time:10-05

created an angular application, ionic application and a custom library in workspace, able to import library files into angular application but not into ionic application. My question is - I have a library in some folder of my local system. Can I use this library in my application without making the package published in npm. How to use a module in my application without publishing it

CodePudding user response:

You could git push it and then add it to your package.json like this:

"dependencies": {
  "cordova-plugin-local-notification": "git https://github.com/katzer/cordova-plugin-local-notifications.git"
}

(that's an actual working import in one of my projects - the imported library is not mine)

CodePudding user response:

If your library is local, you can reference it from your tsconfig.json at the root of your project :

{
    "compilerOptions": {
        "paths": {
            "your-lib-name": ["path/to/your/lib"]
        }
    }
}

Then, everything exported from your library will be available in your project.

import { SomeClass } from 'your-lib-name'; 
  • Related