Skip to content

Instantly share code, notes, and snippets.

@coolaj86
Last active October 29, 2024 21:43
Show Gist options
  • Save coolaj86/1318304 to your computer and use it in GitHub Desktop.
Save coolaj86/1318304 to your computer and use it in GitHub Desktop.
How to publish packages to NPM

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

Then create a package.json and publish it:

cd /path/to/your-project
npm init

npm install -g pakmanager
# this shows you dependencies as you `require`d them
pakmanager deps
# now edit `package.json` and add any deps you forgot aboutt

npm publish ./

More Info:

Appendix:

If you haven't already installed npm, or you'd like the latest version:

OS X

curl http://npmjs.org/install.sh | sh

Linux

curl http://npmjs.org/install.sh | sudo sh
@danawoodman
Copy link

If you're tagging versions, try npm version major|minor|patch which intelligently increments the version number and creates a git tag and package.json version bump.

Copy link

ghost commented Mar 19, 2016

👍

@autopulous
Copy link

Is it possible to publish directly from a GitHub repository (as opposed to publishing from a local machine)? or better said, I'm not able to figure out how to do this... https://docs.npmjs.com/all#repository seems to indicate that the repository can be referenced/extracted from GitHub...

http://stackoverflow.com/questions/35026096/is-it-possible-to-publish-to-npm-directly-from-a-github-repository

👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍

P.S. The first two links in the More Info section are broken

@Obooman
Copy link

Obooman commented Mar 29, 2016

Cool work!Thanks.

@abdghani
Copy link

Is it compulsory to provide a test in publishing a npm package ?

@andreafalzetti
Copy link

Very handy. Thanks 👍

@avaleriani
Copy link

👍

@AmmarHasan
Copy link

+1

@paradigmist
Copy link

👍

@zhangbg
Copy link

zhangbg commented Nov 30, 2016

mark.

@mortezakarimi
Copy link

mortezakarimi commented Aug 9, 2017

+1 👍

@alexandlazaris
Copy link

I'm having issues publishing my npm package. I added name and email using npm set init.author.name + same for email. After I do npm adduser and login successfully. After this I enter npm publish and get this error:

you do not have permission to publish "auto-reload". Are you logged in as the correct user? : auto-reload

Does this mean I must login as my package-name? (auto-reload) This makes no sense to me 🤔

@nuno-nlfsoftware
Copy link

👍

@jonathanarbely
Copy link

jonathanarbely commented Jan 21, 2018

CMD should be started as admin.
Edit: User Accounts should be created on npmjs.com. Then do npm login. Then publish with npm publish ./.

@xizon
Copy link

xizon commented Feb 2, 2018

nice!!

@ryanburnette
Copy link

Can you update this to include horse-npm?

@chattes
Copy link

chattes commented Feb 23, 2018

I published a package to npm but I dont see the linked github repo?
Any ideas?
image

@Aoa77
Copy link

Aoa77 commented Feb 28, 2018

+100

@AugustoAleGon
Copy link

AugustoAleGon commented Mar 27, 2018

I got the same problem!! @chattes

@talentedandrew
Copy link

Published my first npm package react-modern-datepicker

@PetrSnobelt
Copy link

to add linked github repo add repo section to package.json

@hustcc
Copy link

hustcc commented Nov 6, 2018

npm-robbery A command tool to register npm package name conveniently.

@nakulkundra
Copy link

@silviu-burcea Like this one?
https://npmjs.org/doc/developers.html

404

@markolofsen
Copy link

It's really easy if are you using special tool for publications.
It's works in your browser, without any special dependencies.

Try this library for that https://github.com/markolofsen/how_to_upload_package_to_npm

@karan3112
Copy link

Very helpful

@hayatbiralem
Copy link

Thank you, it was fast :)

@kapitannwel
Copy link

very very helpful, worked first time doing it! [+1]

@031nna
Copy link

031nna commented Sep 7, 2020

+1

@amirshnll
Copy link

thanks

@UltiRequiem
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment