Steps to create NPM Package and upload on NPM Server.

Posted on Posted in ReactNative

Steps to create NPM Package and upload on NPM Server.

// Create directory
1:  mkdir TestDemoPackage

 

 

2: cd TestDemoPackage
// Init NPM Project
3: npm init

H:>mkdir TestDemoPackage

H:>cd TestDemoPackage

H:>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> –save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (TestDemoPackage) chavanramesh_react_native_testpackage_5
Sorry, name can no longer contain capital letters.
name: (TestDemoPackage) chavanramesh-testpackage
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords: test
author: Ramesh Chavan <ramesh.pchavan@gmail.com> (http://www.rameshchavan.in/)
license: (ISC)
About to write to package.json
:

{
“name”: “chavanramesh_react_native_testpackage_5”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo \”Error: no test specified\” && exit 1″
},
“keywords”: [
“test”
],
“author”: “Ramesh Chavan <ramesh.pchavan@gmail.com> (http://www.rameshchavan.i
n/)”,
“license”: “ISC”
}
Is this ok? (yes) yes

H:\Development\ReactNative\Module\TestDemoPackage>

//Publish NPM package and you have to must login with npm credentials

 

4:  npm install -g npm
5: npm Publish

H:\Development\ReactNative\Module\TestDemoPackage>npm publish
+ chavanramesh-testpackage@1.0.0

 

//Now the package available to download for everyone with the following command
6: npm install –save  chavanramesh_react_native_testpackage_5

 

//Link module

7:  npm link  chavanramesh_react_native_testpackage_5

Example : https://www.npmjs.com/package/chavanramesh_react_native_testpackage_5

Leave a Reply

Your email address will not be published. Required fields are marked *