Is it possible to automatically access the most recent Beta build through package.json and npm?

We are currently working on a project that has a specific dependency requirement for the latest beta build from an npm library. However, there are also -dev builds within the library.

For instance, in the "x-library" there might be versions like:

"1.2.3-dev.294   // released today
"1.2.3-beta.123" // <--- preferred version released yesterday
"1.2.3-dev.293"  // released a week ago
"1.2.3-beta.122" // released a month ago

Is there a way to automatically fetch and use the latest 'beta' build in the package.json file, like this:

devDependencies: {
  ...
  "x-library": "latest-beta"  // just for clarity
} 

Answer №1

It seems like the functionality you're looking for is not currently supported by npm. Using regex to define your dependency version is also not an option at the moment.

If you want to find a workaround, you could create a bash script named update-and-install.sh and include these steps:

  • Retrieve JSON containing all available versions using

    npm show my-package versions --json

  • Filter the JSON to only get beta versions

  • Utilize the package semver-parser along with its compareSemVer method to identify the latest beta version

  • Use sed to modify your package.json file and set the dependency to the desired version

  • Execute npm install

If this information proves useful, you can give it a try as a potential solution for your project needs. Best of luck!

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

Unable to locate and interact with a specific element within a dropdown menu while utilizing Protractor

I am currently facing an issue with selecting a checkbox from a dropdown in jq widgets. The code seems to work fine when the element is visible on the screen, but fails otherwise. I have tried various methods such as executeScript and scrollIntoView to bri ...

Exploring the validation process for the updated checksum in Yarn v2+ lockfile

Lockfiles in Yarn v1 include an integrity checksum that can be verified against the npm or yarn registry's checksum. accepts@~1.1.0: version "1.1.4" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.1.4.tgz#d71c96f7d41d0fed ...

The React-Virtualized Autosizer component is returning a height value of 0 when used with VirtualScroll

Despite AutoSizer's width providing the correct value, I am consistently encountering a height of 0 for Autosizer. This is causing the VirtualScroll component to not display properly. However, when using the disableHeight prop and setting a fixed heig ...

Problematic situation when using ng-repeat with dynamic ng-include and template variables scope conflict

When utilizing ng-repeat with dynamic ng-include that includes variables, the variables are not being properly recognized. Take a look at this code snippet. Here is the main HTML code: <table style> <tr> <th>Student</th> ...

What is the best way to implement two events in onPress using React Native?

I'm trying to implement the UploadB function and toggle the modal visibility using setModalVisible(!modalVisible)... However, my attempts so far have not been successful. const UploadB = useCallback(() => { dispatch({ type: ADD_P ...

Is there a way to connect a controller to rootDocument without using a directive?

I'm currently developing a custom plugin for bootstrapping my Angular application manually, using the document as the root. I want to attach a controller to my root without utilizing the ng-controller directive in order to create a global controller e ...

Deleting a segment of content from a webpage

Currently, I'm in the final stages of completing a blackjack game. However, one aspect that I haven't implemented yet is the ability for the user to play again after finishing a round. My initial idea is to use a window.confirm dialog box, where ...

Deactivate toggle effect by clicking on a different link

My existing JavaScript code changes the background color of a link when it is clicked: $(".button").click(function(){ $(this).css('background-color', '#555'); }); While this functionality works, I am looking to have the color tog ...

Encountered an issue during Karma unit testing of an Ionic App: the error message [ng:areq] indicates that the argument 'StockCtrl' is not recognized as a function and is

I've encountered an issue while trying to conduct unit testing on my ionic app. Despite checking previous queries, none of the given solutions seem to work for me. Any suggestions on what might be causing this error? The error message I'm receiv ...

Having trouble logging JSON data from nodejs + express while serving static files through express. However, I am able to see the data when I only make a GET request for the JSON data without the static files

Currently, I am experimenting with sending data from a nodejs + express server to the front-end static files. The objective is for JavaScript (allScripts.js) on the front-end to process this data. At this stage, my aim is to log the data to the console to ...

Executing a jQuery script on various elements of identical types containing different content (sizes)

I am currently working on a jQuery script that will center my images based on the text block next to them. Since I am using foundation 5, I have to use a jQuery script to override the CSS instead of using vertical-align: middle. The script looks like thi ...

What causes the DOM to be updated upon each opening of the browser extension for Chrome?

Here is the default position: https://i.stack.imgur.com/tkWCA.png After checking it: https://i.stack.imgur.com/tdzbg.png When I click anywhere on the page to hide the dom extension output (without showing popup.html); However, when I reopen the extens ...

Utilizing Angular 2's offline capabilities for loading locally stored JSON files in a project folder

I've been attempting to load a local JSON file from my Angular 2 project folder using the HTTP GET method. Here is an example of the code snippet: private _productURL = 'api/products/products.json'; getProducts(): Observable<any> ...

JSON: Invalid character detected at index 324

Error: SyntaxError - Unexpected token / in JSON at position 324 Encountered while working on: entity Category { } relationship ManyToMany { Category{parents} to Category{children} } Command used: jhipster import-jdl jhipster-jdl.jh --force N ...

Obtaining the result from within the .then() block

Through the utilization of Google's API, I am successful in retrieving and displaying nearby places on the console. router.get('/', function (req, res, next) { // Locating nearby establishments googleMapsClient.placesNearby({ ...

Determining special characters within a string using VueJS

As a newcomer to VueJS, I am currently developing an application that requires a signup and login system. My goal is to inform the user if they have entered a special character such as /[&^$*_+~.()\'\"!\-:@]/. In order to achieve th ...

Set up a host node module on your local server and integrate it into your application by installing it via

Currently, I am in the process of developing a node package with the following structure: my_module(folder) --package.json (located inside the my_module folder) --other files/folder (contained within the my_module folder) The contents of the package.jso ...

Ways to eliminate a textbox from an HTML table using jQuery or JavaScript while retaining the textbox values

Currently, I am facing a task where I have a table with a column filled with textboxes. My goal is to eliminate the textboxes using jQuery/JavaScript while retaining the values within them. Here are a couple of methods I have attempted: // removes both t ...

Setting up your $PATH by utilizing NVM and then proceeding to install NPM

After successfully setting up NVM, I wanted to install NPM to manage packages for my nodejs application on my digitalocean VPS. Upon typing "node -v" I saw that the 0.10.19 version was installed in the ~/.nvm/v0.10.19/bin folder. Checking "node -v" c ...

Retrieve the element that is currently being hovered over within the same nested selector

I am facing a challenge in selecting the currently hovered element with a nested selector. The ".frmElement" class is used as the selector. When I hover over the ".frmElement" element at a certain level, all the previous selector elements display the hover ...