mylibrary-edison
v1.0.1
Published
A lightweight, beginner-friendly JavaScript utility library exporting the ask function.
Maintainers
Readme
💡 mylibrary-edison
A clean, minimalist, and beginner-friendly JavaScript utility library built using modern Node.js and ES Modules.
📖 Description
mylibrary-edison is an educational, boilerplate-ready NPM package designed to demonstrate how to create, structure, and publish a modern ES Module (ESM) library. Out of the box, it exports a single, ready-to-implement utility function called ask().
It is designed for beginners who want to learn how modern ES module exports work, how to organize a clean package structure, and how to distribute their code via the NPM registry.
🛠️ Project Structure
The project has a clean and beginner-friendly layout with absolute minimal noise:
edison/
├── package.json # Package configuration, metadata, and module entrypoints
├── index.js # Main library file exporting the public API (ask function)
└── README.md # Comprehensive documentation and publishing guideFile Breakdown:
package.json: Configures the project metadata (name, version, author, license) and explicitly declares"type": "module"so Node.js loads files as ES Modules, enabling the use ofimportandexportstatements.index.js: Contains the source code of the library, exporting the single placeholder functionask().README.md: This guide! It describes the library, usage, and publishing instructions.
🚀 Installation
Once published to NPM, developers can install mylibrary-edison using their favorite package manager:
# Using npm
npm install mylibrary-edison
# Using yarn
yarn add mylibrary-edison
# Using pnpm
pnpm add mylibrary-edison💻 Usage Example
Since mylibrary-edison uses modern ES Modules (ESM), you can import it into your JavaScript projects using the standard import syntax:
// Import the ask function from the mylibrary-edison library
import { ask } from 'mylibrary-edison';
// Call the function
ask();[!NOTE] Ensure your consuming application's
package.jsonincludes"type": "module", or that you run your script with an.mjsextension so Node.js recognizes ES modules.
📦 How to Publish to NPM
Ready to share your library with the world? Follow these simple steps:
1. Create an NPM Account
If you haven't already, sign up for a free account at npmjs.com.
2. Log In to NPM via CLI
Run the following command in your terminal to authenticate your machine:
npm loginYou will be prompted for your username, password, email, and a one-time password (OTP) sent to your email.
3. Check for Package Name Availability
Before publishing, make sure the name mylibrary-edison isn't already taken on NPM. If it is, update the "name" field in your package.json to something unique (e.g., @your-username/mylibrary-edison or mylibrary-edison-utility).
4. Publish Your Package
Run the following command to make the package public on the registry:
npm publish --access public🎉 Congratulations! Your library is now live on NPM!
🔢 Semantic Versioning (SemVer) Explanation
NPM packages follow Semantic Versioning rules, represented as MAJOR.MINOR.PATCH (e.g., 1.0.0):
PATCH(e.g.,1.0.1): Incremented for backwards-compatible bug fixes.MINOR(e.g.,1.1.0): Incremented for new backwards-compatible functionality or features.MAJOR(e.g.,2.0.0): Incremented for API-breaking changes that require consumers to update their code.
To update your version before publishing a new release, you can use the npm utility:
# Increments patch version (1.0.0 -> 1.0.1)
npm version patch
# Increments minor version (1.0.0 -> 1.1.0)
npm version minor
# Increments major version (1.0.0 -> 2.0.0)
npm version major📄 License
This project is licensed under the MIT License. Feel free to use, modify, and distribute it as you see fit.
