hello-world-dev-starter
v1.1.0
Published
print hello world from console
Downloads
5
Readme
How to release npm package
npm init -y
This initializes a package.json
file. Next, create an executable script file, let's say hello.js
, with the following content:
#!/usr/bin/env node
console.log('Hello World!');
Now, update your package.json
file to include the "bin" field:
{
"name": "your-tool",
"version": "1.0.0",
"description": "Your description",
"bin": {
"hello": "./hello.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Your Name",
"license": "MIT"
}
Replace "your-tool" with your desired package name and update other fields accordingly. Now, you can test your tool locally by running:
npx ./
Finally, to publish your tool, you need to create an account on npm (if you haven't already). Once that's done, you can use the following command to publish your tool:
npm login
npm publish --access public
Replace "public" with "restricted" if you want to publish it as a restricted package. Now, users can install and use your tool globally with:
npx your-tool
Make sure to replace "your-tool" with the actual name of your npm package.