A simple hello world NPM package for demonstration purposes.
- Clone the repository:
git clone https://github.com/nautilus/publish-npm.git
cd publish-npm
- Install dependencies:
npm install
- Run tests:
npm test
To test the package locally without publishing to npm:
- In the package directory, create a symlink:
npm link
- In your test project directory, link to the package:
npm link @nautilus/hello-world
- Now you can use the package in your test project:
const { sayHello } = require('@nautilus/hello-world');
console.log(sayHello()); // Outputs: Hello, World!
console.log(sayHello('John')); // Outputs: Hello, John!
-
When you're done testing, unlink the package:
a. In your test project directory:
npm unlink @nautilus/hello-world
b. In the package directory:
npm unlink
Once published, you can install the package using:
npm install @nautilus/hello-world
const { sayHello } = require('@nautilus/hello-world');
console.log(sayHello()); // Outputs: Hello, World!
console.log(sayHello('John')); // Outputs: Hello, John!
npm pack --dry-run
- builds
node_modules