What is the correct npm identifier to include in the package.json file?

I am looking to make my library accessible on NPM for the first time.
I want it to be available publicly, so in the package.json file of my library, I have

"name": "firstname-lastname/testlib123"

This means my first name - my last name/

my library name (testlib123 in this case)

However, when I try to publish, I receive an error:

The name is invalid.

In addition, I see a warning in VS Code:

The string does not match the pattern of "^(?:@[a-z0-9-*~][a-z0-9-*._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"".

I'm unsure about regex. Where did I go wrong?

Answer №1

To learn how to create and publish scoped public packages, please refer to this helpful guide:

  1. Make sure you have a user account on the NPM website
  2. When naming your package, be sure to start with @, followed by your NPM username and then the actual package name (e.g., @petar/my-package)
  3. For the initial publish, use: npm publish --access public. Subsequent publishes can be done with just npm publish.

If you're interested in automating releases for private NPM packages, I recommend checking out my article on the topic for a smoother publishing process.


Regarding your regex query, please ensure that it has been accurately copied here. I had to make a minor adjustment to get it to parse correctly. You may also find this regex explanation website useful:

https://i.sstatic.net/9Ppib.png

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

Displaying local time alongside global time using PHP

I have a challenge - I am storing time in DATETIME format and now I need to display it in the local timezone. Does anyone know how to achieve this using PHP? ...

Using React Router (version 4) - navigating backwards in your application

Currently struggling to find a way to navigate back to the previous page using [react-router-v4][1] Here is the setup I have on my initial landing page: <Router> <div> <Link to="/"><div className="routerStyle"><Glyphicon ...

Problems with form functionality in React component using Material UI

Trying to set up a signup form for a web-app and encountering some issues. Using hooks in a function to render the signup page, which is routed from the login page. Currently, everything works fine when returning HTML directly from the function (signup), ...

What could be causing the reliability issue with this particular Angular JS code for dropdown menus?

Attempting to create a dynamic country-city dropdown menu using AngularJS <div> Country: </br> <select data-ng-model="country" ng-options="country.name for country in countries" data-ng-change="updateCountry(country) ...

Modify opacity color of ImageBackground in React Native

I have been working on creating a screen as seen below: To achieve this, I have developed the following component: import React, {Component} from 'react'; import {View, Text, StyleSheet, ImageBackground, Image} from 'react-native'; im ...

Efficient Ways to Present and Personalize Indian Date and Time using JavaScript

Hey there, currently creating my website and need some assistance. I'm looking to display the date and time in different sections of the page. Having some trouble with getting Indian time to work properly using PHP. If you could help me out with Ja ...

Sending the text area upon pressing 'enter' key

There are various solutions available for this issue, but none of them seem to work for me because I am using multiple forms. My inquiry revolves around the need for a script that can submit the data from a textarea upon pressing the Enter key, while stil ...

Show information according to the selection made in the dropdown menu

Greetings! I am currently developing a web app using MVC .NET (C#) that includes a registration page for two types of users, type 1 and type 2. In the form, there is a dropdown list where users can select their type. When selecting type 2, I would like t ...

Tips for Transforming this Function into a Promise in Node.js

My code includes an ajax call that needs to return a promise. The function in question is shown below: client.tickets.create(ticket, function(err, req, result) { if (err) { logger.error(err); return false; } return JSON.stringify(resu ...

Change the :target in javascript

I'm struggling with a CSS challenge: #box:target { box-shadow: 0px 0px 20px black; } Here's the scenario: On my "parent" page (page1), I have a button that redirects you to another page called "page2.html#box". This causes the #box:target s ...

What could be causing the getElementById() function to malfunction?

Currently in the learning process, I am attempting to make a button perform an action - specifically displaying a message using the alert function. However, it seems that the method getElementById is not functioning as expected and I am unsure of the reaso ...

Deactivate specific dates in angular-strap 2.0

With the use of angular-strap v0.7, I successfully utilized Bootstrap's beforeShowDay method to enable/disable specific dates in the datepicker. However, in angular-strap 2.0, I am struggling to locate this feature. Is it available in this version? ...

Tricks for preventing axios from caching in GET requests

I am utilizing axios in my React-Native application Firstly, I set up the headers function setupHeaders() { // After testing all three lines below, none of them worked axios.defaults.headers.common["Pragma"] = "no-cache"; axios.defaults.heade ...

HTML: Ensure that a user fills out a minimum of one text box before submission

<tr><td> First Name: </td><td><input type="text" name="FirstName" required></td> </tr> <tr><td> Last Name: </td><td><input type="text" name="LastName" required> </td></tr> ...

Event handler vanishes within the context of ng-repeat

My form in HTML contains multiple questions generated with ng-repeat. I am trying to implement a pop-over for certain questions. Interestingly, the pop-over works when the triggering button is outside the ng-repeat but not inside. Here is an example of it ...

Component in React/JavaScript designed for transmitting data to ASPX backend

I am in the process of updating a legacy ASP.NET application to modernize it. One specific page that I am working on is MyPage.aspx, along with its corresponding codebehind file MyPage.aspx.cs. In order to enhance the functionality of a custom user contro ...

Ways to regain control of the iframe window once a popup has been launched

I have a question regarding managing windows in Javascript. In my application, when I click on a link within an iframe, it opens a popup window where I enter my login credentials. After entering the credentials, I am able to close the popup window using a ...

Ways to conceal a div using jQuery when the video source is missing

If there is no source in the video, I want to hide the video_wrapper class <div class="video_wrapper" style="width: 100%; height: 100%; display: none;"> <video id="df-video" playsinline="" webkit-playsinline="" style="height: 100%; width: 100%; ...

Handling form submissions in Vue.js before navigating away from the current route

As a newcomer to VueJs, I am facing a problem with creating a form. My goal is to display an alert dialog with the message "you might lose the data, please save the data before you leave," and upon clicking 'yes', the form should be submitted and ...

Get the name of the form I am submitting using jQuery

Looking to create a jQuery script that can serialize the formData being submitted from any HTML page. The challenge arises when there are multiple forms on a single page - how do I distinguish which form is being submitted? My goal is to track activities o ...