npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

axelsminipaket

v1.0.3

Published

Trying out my own npm package.

Downloads

6

Readme

Npm package experiments

I've created this repository to experiment with npm packages. I want to create, publish and update npm packages. I also want to make git tags and use the script property "prepublish" in package.json to call grunt tasks. I want to be able to only publish distribution files and not source files.

I want to understand what's being copied to the "npm modules" folder when someone calls "npm install ". The package that I finally created publishes a dist folder. This folder is not in the repository but gets created when the package is published using the prepublish property in package.json.

##Creating an npm package

  • Follow these instructions to create an npm package https://docs.npmjs.com/getting-started/creating-node-modules
  • To use grunt, grunt-contrib-jshint and grunt-contrib-concat I first installed the packages using: npm install <package> --
  • I created a .ignore file so that node_modules and bower_components do not get copied to github.
  • Configured Gruntfile.js following the instructions in http://gruntjs.com/sample-gruntfile
  • I started with some simple tasks. Running jshint and concatenating files to the dist folder creating a main js file that has the same name as the name property in the package.json file.
  • I added a main property to package.json as "dist/axelsPakettest.js". This file is what's loaded when the npm package is loaded when the module is required.

##Publishing the package axelsminipaket

  • Create or login as an npm user. You can either register a user or login as an existing user using the command npm adduser. You may have problems login in if your npm version is too old. It happened to me.
  • Publishing your package is as easy as calling the command: npm publish.
  • I used this site https://docs.npmjs.com/getting-started/publishing-npm-packages
  • I discovered that if I use dependencies instead of devDependencies in package.json the dependencies get installed along with the package at installation.
  • I'm also using the files-properties in package.json to only install the dist-folder when the package gets installed.
  • To make a new version of the package you can edit the package.json manually or you can use "npm version patch", "npm version minor", "npm version major" depending of what kind of update you are doing. Using the "npm version" command in a git repository you automatically make a tag. You will have to push the tag manually to github.
  • After making a new version you have to call "npm publish" again.

Installing the package

  • When I use "npm install axelsminipaket" only the dist folder, package.json and the readme file gets copied.
  • If I use "npm install edminsson/mini_npm" only package.json and the readme file gets copied. That could be because the dist folder is not in the repository. I tried to add an extra folder to both the files property in package.json and to the repository and this new folder gets copied when installing the package directly from github without using the published package.
  • The main file in the package also contains a printMsg in the exportsobjekt so it can be used when the package is required. I.e. demo = require('axelsminipaket'); demo.printMsg();

##Commands

  • npm adduser or npm login
  • npm publish
  • npm version patch (updates the last digit in the version 1.0.1 to 1.0.2. If it's a git repo it creates a tag and commits it)
  • After "npm version patch" you must do a new "npm publish"