Is it possible to create a package for npm?

Hello glitch, is it possible to create a package to put on NPM?

I can’t see why not :slight_smile:

1 Like

https://docs.npmjs.com/creating-node-js-modules

1 Like

Hi @IgorWL - you can definitely create and publish packages to NPM from Glitch - for example, I made the friendly-emoji package and i build it on https://glitch.com/edit/#!/friendly-emoji and whenever I make an update I bump up the version in package.json and run publish from the editor’s terminal.

5 Likes

Hey @jenn there is currently a problem with Glitch!

Hey @impressiveaustin I’m not having any issues right now on my end, but if you’re having an issue with a project you should email support@glitch.com or create a new forum topic!

So, I just run npm publish and Glitch will publish it?

I think if you have a package.json with name, description, author, etc., yes.

Hey @R4356th,

You need to create an account on NPM first. Then run npm adduser which will ask you for details for signing in, such as your username, password and email. Then you can run npm publish.

Creating an NPM package is quite easy, it’s basically a function (or object or a variable) that is being exported which can be used by other files.

I recommend this article, which will help you create your first NPM package: https://dev.to/therealdanvega/creating-your-first-npm-package-2ehf.

There are few requirements, like your package.json should have a name (the name should be unique; the name field in the package.json is what gives the name of the package, so it must not be a name used by an existing package), a description, link to the GitHub repo, contributor info and keywords.

It’s also a good practise to use semantic versioning to keep proper versioning of your packages. Everytime you publish to NPM, the version number has to be unique or else it won’t publish.

Have a great time creating packages!

4 Likes

Thank you very much for the detailed reply!

2 Likes