npm publish does not include build files

Discussão em 'Angular' iniciado por GinoMartino, Março 4, 2025.

  1. GinoMartino

    GinoMartino Guest

    I am trying to create a web component using angular. So far so good. My goal is to publish it to GitHub Packages and for that I am using an Action. This is the job doing the building and publishing.

    build-publish-release:
    needs: create-release
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    with:
    fetch-depth: 0

    - name: Setup Node.js
    uses: actions/setup-node@v4
    with:
    node-version-file: '.nvmrc'
    cache: npm

    - name: Install Dependencies
    run: npm install

    - name: Build
    run: npm run build:prd

    - name: Cleanup
    run: |
    rm dist/web-component/index.html
    rm dist/web-component/prerendered-routes.json

    - name: Authenticate with GitHub Registry
    run: |
    npm set @My-Scope:registry=https://npm.pkg.github.com
    npm set "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}"

    - name: Publish
    run: npm pack && npm publish
    env:
    NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


    As a result, when I install the published package into a project and inspect it in the node_modules folder, things get weird. The only files included in the package are: LICENSE, README.md and package.json.


    • I added the files array to the package.json, which looks like this: "files": [ "dist/**/*" ]


    • I added an .npmignore which has the same content as my .gitignore, just without dist

    Continue reading...

Compartilhe esta Página