NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 195 forks source link

Managing npm packages -package.json file path #2884

Closed augmen closed 7 years ago

augmen commented 7 years ago

hi i am building video streaming app through telerik platform. My app structure looks like :

my-project app

I have added firebase and bitmovin player plugin to my node_modules. Now the Telerik platform documentation says : to add require references to package.json file. screen shot 2017-06-12 at 18 28 53

I do not get which package.json file needs to be opened . There are two files. The first one in the Project root which looks like: { "dependencies": { "tns-core-modules": "2.5.1", "bitmovin-player": "7.2.0-rc6", "firebase": "4.1.2" }, "devDependencies": { "nativescript-dev-android-snapshot": "0.0.6", "@types/firebase": "2.4.31" } }

The other package.json file is in the app folder looks like : { "name": "tns-template-blank", "main": "app.js", "version": "2.5.0", "author": "Telerik <support@telerik.com>", "description": "Nativescript blank project template", "license": "Apache-2.0", "keywords": [ "telerik", "mobile", "nativescript", "{N}", "tns", "appbuilder", "template" ], "repository": { "url": "https://github.com/NativeScript/NativeScript/commit/30aca890749e9e3fb9bd0f5ddc9de5b6995859bc" } }

and the app.js file looks like : var application = require('application'), mainModule = 'navigation/navigation'; application.start({ moduleName: mainModule });

I do not get in which package.json file needs to be configured and where to enter the require reference for the module (like bitmovin player & firebase ) as mentioned in the telerik platform documentation which is shown in the picture above step no. 8.

please guide.

rosen-vladimirov commented 7 years ago

Hey @augmen , When you want to add a new plugin, there are two ways to do it via Telerik Platform:

No matter how you add your plugin the usage in your project should be:

var lodash = require("lodash");

The NOTE in the Telerik Platform documentation says that the name in the require should be the real name of the package. For example in case you add lodash, you will write require("lodash") in your code.

Hope this makes it clear.

augmen commented 7 years ago

Respected : Thanks for feedback. I want to know the file and place where to add the var lodash = require("lodash”); references ? shall i add to my package.json file in the root of my project ? or to app.js file in the app folder ? or to homeview.js file in the home folder subdirectory of app folder ?

Swapnil Bhadade swapnilrbhadade83@gmail.com Nagpur India

On 13-Jun-2017, at 12:32, Rosen Vladimirov notifications@github.com wrote:

var lodash = require("lodash");

rosen-vladimirov commented 7 years ago

@augmen , the require should be placed in the files where you use it, for example in case you need lodash in your homeview.js, add the require only at the top of it. You should never add require in your package.json file

augmen commented 7 years ago

where to add firebase plugin var file . as firebase is used for the whole app. shall i need to firebase plugin var references to my app.js ?

Swapnil Bhadade swapnilrbhadade83@gmail.com Nagpur India

On 13-Jun-2017, at 12:44, Rosen Vladimirov notifications@github.com wrote:

@augmen https://github.com/augmen , the require should be placed in the files where you use it, for example in case you need lodash in your homeview.js, add the require only at the top of it. You should never add require in your package.json file

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/nativescript-cli/issues/2884#issuecomment-308028410, or mute the thread https://github.com/notifications/unsubscribe-auth/AK9uTB1AuO5rymZoURSVuAvGhUdUWFD3ks5sDjbSgaJpZM4N3Nlb.

rosen-vladimirov commented 7 years ago

@augmen , you should add the plugin in the files where you use it. When you use require it caches the instance, so you'll use the same one in all the files. For example in case you need to use the plugin in file named myFile1.js and in myFile2.js, place the require at the top of both files and use it. The instance of the plugin will be the same one, that's how the require works.

rosen-vladimirov commented 7 years ago

Hey @augmen , I believe we've resolved the initial question, is it okay to close this issue?

augmen commented 7 years ago

Thanks Best Swapnil Bhadade swapnilrbhadade83@gmail.com Nagpur India

On 14-Jun-2017, at 11:46, Rosen Vladimirov notifications@github.com wrote:

Hey @augmen https://github.com/augmen , I believe we've resolved the initial question, is it okay to close this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/NativeScript/nativescript-cli/issues/2884#issuecomment-308330356, or mute the thread https://github.com/notifications/unsubscribe-auth/AK9uTG8y0hNr_o05UVmuFKHbpSx4YE9yks5sD3ragaJpZM4N3Nlb.