Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.25 KB

Build-Package.md

File metadata and controls

55 lines (40 loc) · 1.25 KB

Build and Publish an npm First Package

LINK 1

SETUP

Create an empty directory and initialize it as a npm package using npm init or npm init --yes, if you're feeling lazy. It will ask you to create your package.json file.

# Create the project directory
mkdir random-number-generator 

# Change into the project directory
cd random-number-generator     

# Initialise an NPM package
npm init

Let's start creating our script file index.js

exports.init = function() {
    const jsonfile = require('jsonfile');
    const file = './package.json'
    jsonfile.readFile(file, function (err, obj) {
    if (err) console.error(err)
        console.dir(obj.version);
    })
}

How to start main index.js from my package.json file

Publish Package

npm login
npm publish

Create a build.js file and run this file node build.js

var repeat = require('chrome-extension-builder');
repeat.init();
  • Test your new NPM module without publishing it
  • Create a new file package current directory example.js
var foo = require('./index')
foo