Error in GitHub Action: Uploading NPM Package

I encountered an issue with the "publish npm package github action"

name: Publish package on NPM

on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: 16.x
          registry-url: https://registry.npmjs.org/
      - run: yarn
      - run: yarn build
      - run: npm publish --access=public
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

and I am facing this error :

npm ERR! code EPRIVATE

npm ERR! This package has been marked as private
npm ERR! Remove the 'private' field from the package.json to publish it.

However, the package is not private and I was able to publish it using the command in VSCode by simply typing "npm publish --access=public". So, why isn't it working with my GitHub action? It seems to be doing the same thing as when I did it manually

Thanks!

Add private: falseto package.json Remove private property from package.json Delete package-lock.json and npm i

Answer №1

You are encountering an error because of the following reason:

If you include "private": true in your package.json file, npm will not allow you to publish it.

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#private

Even if there is no private field in your package.json, you may still receive this error:

Note: When using the --access flag with the npm publish command, it will only set the package access level during the initial publication. Any subsequent npm publish commands with the --access flag will not impact the access level. To modify the access level after the initial publication, use npm access.

https://docs.npmjs.com/cli/v8/commands/npm-publish#access

This means that if you previously published the package with a different access level (such as restricted, which is the default for scoped packages starting with @), you must update the access level to public before attempting to publish.


Additionally, make sure to upgrade actions/checkout and actions/setup-node to utilize Node.js version v16.

steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16.x
          registry-url: https://registry.npmjs.org/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Attempting to dynamically update the image source from an array when a click event occurs in a React component

Has anyone successfully implemented a function in react.js to change the image source based on the direction of an arrow click? For instance, I have an array set up where clicking the right arrow should move to the next image and clicking the left arrow s ...

I tried utilizing the useState hook to store the value, but surprisingly, it failed to update

I am brand new to Reactjs and currently working on creating an address form that includes 3 select options for country, state, and city. I have implemented React hooks in my project, where the page fetches a list of countries upon initial load. Subsequentl ...

Issues concerning the application of Nextjs and tailwind styling have arisen

My goal is to achieve a scroll effect where my navbar changes color as the user scrolls down the page. However, I am currently facing an issue where the colors are not registering inside the ('') and the navbar remains white (#ffffff) regardless ...

Is it possible to dynamically modify the className of a specific tr in the antd table?

In my Ant Design table, I have a toggler button in each row. When the user clicks on it, I want to add or remove a specific class from that row's parent element. While there are ways to do this with vanilla JS, I am working with the React library and ...

Pause the React rendering process to initiate a redirection

Currently, I am developing a React application using Next.js and facing a specific challenge that requires a solution: There are certain pages in my application that should only be accessible once a particular context has been established. To achieve this ...

Having trouble with clearInterval in React TypeScript?

I have been encountering issues with the clearInterval function in TypeScript for React. I am not sure why the interval is not being cleared. To address this problem, I defined a variable let interval_counter;, and used it as follows: interval_counter = ...

What are the steps to configure npm install at the system level?

Each time I develop a new app for Angular 6, running npm install becomes quite time-consuming. Presently, I have uploaded my Angular app to TFS without including the node_modules folder. Consequently, when my team members update the codebase, they must als ...

Experiencing a repetitive occurrence of the error: "SyntaxError: Encountered an invalid or unfore

I've encountered a persistent error when attempting to execute my index.mjs file. Here is the content of my index.mjs file: import WebSocket, { WebSocketServer } from "ws"; import http from "http"; import express from 'express ...

"React - encountering issues with state being undefined when passing child state up through parent components

I am currently navigating the world of react and have encountered a hurdle. I find myself facing difficulties in updating the parent component based on changes in the child state. I was able to pass the child state to the parent by linking the child's ...

Experiencing challenges accessing information from the useEffect hook in React

I'm facing some issues with my useEffect hook and I can't seem to figure out why it's not working. I've been trying to make a call to an endpoint, but it seems like I'm not getting any response back. Any help would be greatly appr ...

Validation of files in the material-ui dropzone is causing rejection errors

I am currently using the material-ui dropzone for file uploads. I have been attempting to validate files upon drop or add, and need a way to reject them if they are deemed invalid. Unfortunately, I have not been able to figure out how to reject the files. ...

Leveraging UseParams for Detailed Product Pages

I am in the process of developing a product detail page using the useParams Hook in my ReactJS application. Unfortunately, I have encountered some issues as I am able to retrieve the ID from the URL but unable to fetch the item's title, image, and pri ...

Received an error when attempting to run "npm install" in the angular-phonecat directory

Encounter Error: > [email protected] postinstall D:\prem\angular\angular-phonecat > bower install bower ENOGIT git is not installed or not in the PATH npm ERR! Windows_NT 6.1.7600 npm ERR! argv "C:\\Program Files&bsol ...

Running "npm start" does not automatically recompile or display code changes

My experience with my Angular project has been smooth until today. Surprisingly, without making any changes, the "npm start" command suddenly stopped working properly. The project compiles successfully, but any subsequent code changes do not trigger an aut ...

The Material UI Icon rendered using document.createElementNS in React is failing to load properly

I'm currently developing a tags section for my app, similar to the tags feature in a new Stack Overflow question form. For this, I am utilizing the Material UI close icon. You can see how it is implemented in this tutorial on YouTube. (I have confirme ...

Encountering an Issue with NPM Run Production in PostCSS

I keep encountering the same error whenever I attempt to execute 'npm run production'. The remainder of the error consists of a compilation of 'node_modules' packages where this issue is also present. ERROR in ./resources/assets/sass/ap ...

Fetching the exchanged messages between the sender and recipient - utilizing MongoDB, Express, and React for chat functionality

I am dealing with two collections named students and teachers in the mongodb database. The structure of a conversation between a student and a teacher involves arrays of messages within each object, as well as the IDs of the sender and receiver. I am seeki ...

Guide to deploying to Elastic Beanstalk with CLI while managing Private NPM Packages

We rely on various namespaced private packages from NPM in our development process. During the deployment procedure with EB CLI (eb deploy), we encounter an issue when EB tries to execute npm i. This results in a deployment failure since EB lacks access t ...

The issue appears to be that the setState function is not functioning as expected

My apologies for the repeated question, but I have not been able to resolve my code issue despite going through all previous answers. In my code, I am attempting to read the URL parameter using queryString and update the state with it using setState(), al ...

Combining two numbers retrieved from Firebase using React

Hello, I am new to React and finding it challenging to perform mathematical calculations with React. I have been attempting to add two values retrieved from a Firebase database, but they keep displaying as strings without adding the actual values together. ...