mkdir shared-types
cd shared-types
npm init --scope=@your-org -y
- Open your terminal and run the following command, replacing
YOUR_GITHUB_USERNAME
with your actual GitHub username:npm login
Ensure your package.json
is set up correctly for GitHub Packages:
{
"name": "@your_github_username/your-package-name",
"version": "1.0.0",
"description": "Your package description",
"main": "index.js",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"scripts": {
"build": "tsc",
"prepublish": "npm run build"
},
"description": "",
"files": ["dist"],
"dependencies": {
// your dependencies
},
"devDependencies": {
// your dev dependencies
}
}
npx tsc --init
Update the ts.config
{
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
"declaration": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}
Run the following command to publish your package:
npm install
# Make sure to delete the ./dist folder before building
npm run build
# patching the version
npm version patch
# For GitHub Packages:
npm publish
If you encounter any errors, check the logs for more details. You can find the logs in the path mentioned in the error message, such as:
# Check for Existing Versions
npm view @realkoder/antik-moderne-shared-types versions --registry=https://npm.pkg.github.com
# use npm version command to increment version automatically
npm version patch
npm install @realkoder/antik-moderne-shared-types@latest