Why does npm install a different version of a dependency than what is listed in the package-lock.json file?

node -v
v17.2.0

npm -v
8.1.4

package.json

{
  "name": "untitled",
  "version": "0.0.0",
  "private": true,
  "devDependencies": {
    "stylelint": "^14.1.0"
  }
}

npm i
npm list postcss

/* Output:
└─┬ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a191e13060f0603041e2a5b5e445b445a">[email protected]</a>
  ├─┬ <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="26564955524555550b554740430b564754554354661008160816">[email protected]</a>
  │ └── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ccbca3bfb8afbfbf8cf4e2f8e2f8">[email protected]</a> deduped
  └── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a8d8c7dbdccbdbdbe890869c869c">[email protected]</a> (why is here version 8.4.4 ???)
*/

Stylelint repository main branch release 14.1.0 package.json postcss dependency: https://github.com/stylelint/stylelint/blob/fcd5ac1ffa4f2ad1f06cb2277aad035ffe309ccc/package.json#L135 is 8.3.11

The query arises as to why npm is installing version 8.4.4 instead of the expected 8.3.11 for postcss. Is there something I am overlooking?

Answer №1

The postcss version referenced in the provided link is ^8.3.11. By using the caret symbol, it indicates that the version is "compatible with" and will automatically update you to the latest minor + patch version available. For more information on this, refer to the npm documentation.

Additionally, it's important to note that this refers to the package.json file and not the package-lock.json, which does indeed lock you into a specific major.minor.patch version.

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

Gone in a flash: the sudden vanishing act

I want to return error messages to the client without adding them to the URL. Here is my approach: exports.register = function(req, res) { if (req.body.password != req.body.password_repeat) { res.locals.err = 'Passwords must match.'; ...

Commitments and incorporating items from an array into objects nested within a separate array

My current project involves a command line node application that scrapes valuable data from a specific website and stores it in a CSV file. For the scraping functionality, I am utilizing scrape-it, which enables me to successfully extract all the necessa ...

A new option to replace package.json, specifically tailored for globally installed npm packages

My project has a standard package.json file that lists the packages being used. In addition to these packages, I need to install some global packages. Rather than doing this manually every time, I'd like to have them listed in a separate file called ...

How to retrieve error messages using Passport JS in Node.js

This is my custom user authentication implementation using Passport Local Strategy. passport.use( new Localstrategy({usernameField:'email'}, (email, pass, done) => { console.log(pass); user.findOne({email: email}).t ...

Transfer data from Node.js to J2ee via binary upload and receive a corresponding reply

I am in need of assistance with my Node express server. The server receives a binary file (pdf) from a client and I must send this binary file as it is to a Java servlet. Currently, I am using the following code snippet to accomplish this task by utilizing ...

Encountering a problem with library functions while attempting to import a module

At the moment, I am utilizing NodeJS. I have been attempting to import a module into a component function and everything appears to be running smoothly. However, I keep encountering this error in the server console: error - src\modules\accountFu ...

Is my DynamoDb connection closed after every use?

I'm trying to figure out if my Dynamodb connection closes every time I run a command. const dboperation1 = async(param) =>{ const docClient = new AWS.DynamoDB.DocumentClient(); const result = await docClient.query(params).promise(); ret ...

Facing Syntax Errors When Running Ng Serve with Ngrx

Currently, I am enrolled in an Angular course to gain proficiency in ngrx. In a couple of months, I will be responsible for teaching it, so I am refreshing my memory on the concept. Strangely, even after installing it and ensuring my code is error-free, er ...

Encountering the below error message when running the command to initialize expo project:

Dependency installation in progress... Warning: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="accfc3dec981c6dfec9d829e829b">[email protected]</a> is deprecated, consider upgrading to core-js@3 or a ne ...

standard_duration for Junior Selenium experiments

Is there an equivalent to Capybara's (RoR) default_wait_time for the Intern? setPageLoadTimeout and setFindTimeout don't seem to accomplish anything. this.timeout = 60000 seems to give an entire test 60 seconds, but I want all steps to have a d ...

Trouble loading CSS file in Vue library from npm package

When using vue-cli to build a library (npm package) that functions for both SSR and client-side, everything seems to be functioning correctly except for one issue; the CSS only loads if the component is present on the page being refreshed. However, when ac ...

Headers cannot be modified after they have been sent to the client in Node.js and Angular

I am working on developing login and registration services using Nodejs Express. Every time I make a request in postman, I consistently encounter the same error: https://i.stack.imgur.com/QZTpt.png Interestingly, I receive a response in postman (register ...

problem with asynchronous functions in sails.js

I decided to put sails.js asynchronous performance to the test by writing a code snippet that would wait for 10 seconds. My expectation was that the code should be executed asynchronously due to the callback function. Upon visiting the URL where the code w ...

Tips for displaying the contents of `[object Promise]` within koa2

I have a query let data = ctx.get("list.json"); ctx.set("Content-Type", "application/json"); await ctx.render('index', { somecontent:onecontent, seconddata: list }); In index.ejs &l ...

Error: Callback function in Mongoose Populate is returning undefined

I have a query set up in MongoDB where I am trying to display all subcollections of the schema while excluding the account ID. The issue is that I am getting "undefined" as the result for the callback "list_data". Here is how my query looks in my routes: ...

Tips on verifying the count with sequelize and generating a Boolean outcome if the count is greater than zero

I'm currently working with Nodejs and I have a query that retrieves a count. I need to check if the count > 0 in order to return true, otherwise false. However, I am facing difficulties handling this in Nodejs. Below is the code snippet I am strugg ...

Issue with the node.js Express generator app failing to respond at the moment

I have only made changes to the main app.js file after installing express generator and npm install. I am inexperienced, so it's possible there is a typo in the app.js file. Here is the file and console output. Thank you for your help. When I try to a ...

Is it possible to skip the 'npm install' command?

Situation In my .NET project, we utilize various npm packages for our UI. I have implemented a pre-built check that verifies if the folder node_modules is missing, and if so, it runs the command npm install. However, when modifying the package.json file ...

`MongoDB impatient for query outcome`

Upon trying to pass the 'db' from my server.js file, where I establish a connection with MongoClient, to routes/api.js for post requests, I encountered an issue. The error message I consistently receive is: TypeError: Cannot read property &apo ...

Getting callback data from a function in the AWS SDK without using asynchronous methods

I have a code snippet that fetches data from AWS using a function: main.js const { GetInstancesByName } = require("./functions"); var operationmode = "getinstances"; if (operationmode == "getinstances") { let getresult = ...