@diyawanna/my-first-package
v1.0.1
Published
My first npm test package
Readme
📦 @diyawanna/my-first-package
My first NPM test package — a simple utility that says hello 👋
Published by @diyawanna
✨ Features
- 🔹 Lightweight and easy to use
- 🔹 Returns a custom greeting
- 🔹 Useful as a base template for future NPM packages
🚀 Installation
Install the package via NPM:
npm install @diyawanna/my-first-package🔧 Usage
In JavaScript (CommonJS)
const { sayHello } = require('@diyawanna/my-first-package');
console.log(sayHello("World"));
// Output: Hello, World! From @diyawanna package.In TypeScript / ES Modules
import { sayHello } from '@diyawanna/my-first-package';
console.log(sayHello('Diyawanna'));
// Output: Hello, Diyawanna! From @diyawanna package.🔍 Local Development & Testing
A. Link the Package Locally
In your package directory:
npm linkIn your consuming project (e.g., Ionic or Laravel):
npm link @diyawanna/my-first-packageB. Use in Your Project
Example for Ionic Angular:
import { sayHello } from '@diyawanna/my-first-package';
console.log(sayHello('Ionic App'));Example for Laravel (with a frontend build):
import { sayHello } from '@diyawanna/my-first-package';
console.log(sayHello('Laravel'));C. TypeScript Support (Optional)
If using TypeScript:
Add a
tsconfig.jsonfile.Compile the source with:
tsc🛠️ Development Commands
- 🔧 Build (if using TypeScript):
tsc - 🔄 Link to another project:
npm link @diyawanna/my-first-package - ❌ Unlink when done:
npm unlink @diyawanna/my-first-package
📦 Publishing to NPM
To publish your package publicly (required for scoped packages like @diyawanna/*):
npm publish --access publicℹ️ Without
--access public, scoped packages are private by default.
📁 Repository Structure
my-first-package/
├── index.js # Entry point
├── package.json # Package metadata
└── README.md # This file🧪 Example Function
index.js
function sayHello(name) {
return `Hello, ${name}! From @diyawanna package.`;
}
module.exports = { sayHello };🐛 Issues & Feedback
Have a suggestion, question, or bug report?
👉 Open an issue on GitHub
📄 License
MIT License
🙌 Author
Made with ❤️ by @wsmr
Published under the @diyawanna namespace.
🔗 Useful Links
- 📦 NPM Package: @diyawanna/my-first-package
- 💻 GitHub Repository: github.com/Diyawanna/my-first-package
✅ After Saving It
- Place this in your project root as
README.md. - Run:
npm publish --access public
