天天看點

[NPM] Publish npm packages using npm publish

In this lesson we will publish our package. We will first add a <code>prepublish</code> script that runs our <code>build</code>script; this will ensure the built folder gets added to npm when published. We will also add a <code>.npmignore</code> so that only our built files get installed. We need to run <code>npm adduser</code> to log in to an npm account. We can then run <code>npm publish</code> to publish our package and view it on npm.

Note: if you want to actually publish the package from this course, you'll need to rename it since <code>sensitive-words</code> is already taken. You can use a scoped package name for this as well.

Inside our .npmigore:

script:

Add prepublish script, so that everytime we publish the lib, will make sure use the latest code.