{
"name": "sabbir-npm",
"version": "1.0.0",
"description": "",
"main": "lib/index.js",
"categories": ["Education", "Other"],
"keywords": ["sabbir", "npm-package"],
"author": "Sabbir",
"license": "MIT",
"devDependencies": {
"nodemon": "^3.0.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"xo": "^0.56.0"
},
"scripts": {
"test": "xo --fix",
"build": "tsc",
"prepare": "npm run build",
"dev": "nodemon src/index.ts"
}
}
{
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"declaration": true, // this will create a .d.ts file based on main file
"outDir": "lib",
"strict": true
}
}
node_modules
pnpm-lock.yaml
package-lock.json
lib
export { Package } from "./package";
export class Package {
generate = (length: number = 5) => {
let result: string = "";
for (let i = 0; i <= length; i++) {
result += i;
}
console.log(result);
};
}
To test our recently created package then just follow these step
npm link
npm link sabbir-npm
Publish your npm package to npmjs
then follow these step
https://www.npmjs.com/login
npm login
Then just press enter to open with browser to login. If is it successfully login then your will see like this message Logged in on https://registry.npmjs.org/.
npm publish