The below code snippet demonstrated the basic usage of plugin. Note that each plugin might have its configuration that needs to be satisfied so always check carefully the plugin's documentation and the README file. Once the plugin you need is installed, you can start using it in your project. Example package.json file using both dependencies and devDependencies can be found here. The devDependencies should not be installed as dependencies to avoid large output build files (large application size). On the other hand, the is a developer dependency required only for intelliSense during the development process. Example for dependency is the plugin which is required runtime so you could use the hardware camera. Note: The difference between dependencies and developer dependencies is that dependencies are required to run, while devDependencies are needed only during development. To achieve that, use the npm install command with -save-dev flag. If you need to install a developer dependency in your project (e.g., like or then you will need to explicitly save it as a devDependency. Installing Plugins as Developer DependenciesĪs shown above the command tns plugin add is actually doing npm i -save behind the scenes. ![]() During this process, the NativeScript CLI adds the plugin to your project’s root package.json file and also resolves the plugin’s dependencies (if any). The NativeScript CLI downloads the plugin from npm and adds the plugin to the node_modules folder in the root of your project. The installation of a NativeScript plugin mimics the installation of an npm package. ![]() tns plugin add you prefer, you could use the NPM command npm install instead of the NativeScript CLI command plugin add. tns plugin add įor example, the following command installs the NativeScript camera plugin. Once you’ve found the plugin you need, install the plugin into your app using the tns plugin add command. If you’re still not finding what you need, you can request the plugin as an idea on the NativeScript community forum, or you can take a stab at building the plugin yourself. ![]() There’s a chance that the functionality you need is built in. The NativeScript team and community may be able to help find what you’re looking for.Īlso, make sure to look through the NativeScript core modules, which ship as a dependency of every NativeScript app. If you can't find a plugin, try asking for help on Stack Overflow. For example, a search of “nativescript accelerometer” would point you right at the NativeScript accelerometer plugin. A search for “accelerometer” on the plugins marketplace will point you at the plugin you need.Īlternatively, since NativeScript plugins are npm packages, you can find NativeScript plugins on npm’s site by searching for “nativescript-plugin-name”. All plugins listed in the marketplace are accompanied by a metadata describing their quality. ![]() The NativeScript team maintains an official marketplace, which displays a filtered list of NativeScript-related plugins from npm. Therefore, finding, installing, and removing NativeScript plugins works a lot like working with npm packages you might use in your Node.js or front-end web development. NativeScript plugins are npm packages with some added native functionality.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |