Don't forget to adjust shrinkwrap.json when a dependency is relocated to the devDependencies section

After mistakenly running npm i --save xxx and having my shrinkwrap.json updated correctly, I realized I actually wanted to use --saveDev.

I began exploring solutions on how to revert this mistake. My initial thought was to run npm uninstall --save xxx, but to my surprise, the library was removed from package.json without updating the shrinkwrap.json file.

Is there a way to undo this action?

Thank you!

Answer №1

It seems that there is an issue with specific versions of npm. To resolve this, consider updating your local npm installation.

If updating npm does not solve the problem, you can set up a postuninstall script to automatically re-shrinkwrap each time a package is uninstalled:

"scripts": {
    "postuninstall": "npm shrinkwrap"
}

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

How can I retrieve a list of local branches using NodeGit?

I am currently developing a node API server that is tasked with sending users a list of local branches from a git repository located on the server. Many sources recommend using NodeGit's Repository#getReferenceNames method, which is exactly what I hav ...

Narrow down product selection by multiple categories

I'm currently in the process of working with Express and MongoDB, where I have data items structured like the following: { "_id": { "$oid": "63107332e573393f34cb4fc6" }, "title": "Eiffel tower&quo ...

Why is it necessary to use ejs in this context?

When looking at various ejs code examples, I often come across similar snippets like the following: // ... const ejs = require('ejs'); // ... app.set('view engine', 'ejs'); app.get('/', function(req, res) { res.r ...

Tips on setting up Jenkins CI/CD pipeline for a Node.js application that is executed through Docker Compose

I have a NodeJS application that has been dockerized. The application is being run on a server using docker compose. Dockerfile: FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 3030 CMD ["npm", "start"] docker-compose.yml ...

Configuring the maxAge setting in Node.js Express

What happens if I specify maxAge in the sendFile() method as shown below: res.sendFile('public/index.html', {maxAge: 100000}) Will this cache the file 'public/index.html' in the server's memory for 100 seconds? Or is it simply a ...

How can I incorporate HAML and SASS into a non-Ruby project with ease?

I am exploring the use of haml with sass to create templates without relying on rails. One challenge I am facing is including haml partials properly. Here is the current structure of my project: build source -- scss -- js -- views --- pages ---- home.ha ...

Generating a file using buffer information in node.js

From the front-end client side, I am sending a file to the server. On the server-side, the data received looks something like this: { name: 'CV-FILIPECOSTA.pdf', data: <Buffer 25 50 44 46 2d 31 2e 35 0d 25 e2 e3 cf d3 0d 0a 31 20 30 20 6f 6 ...

A guide to implementing a For-Each Loop on Argument Array within Functions using Java Script

My code is not functioning properly. I am trying to calculate the sum of numbers provided by the user as arguments. I have attempted to use the Argument Object, but I can't seem to figure out what mistake I've made. // The Argument Object funct ...

Typedoc Error: Attempted to assign a value to an undefined option (mode)

After installing typedoc with the command npm install typedoc --save-dev, I proceeded to add typedocOptions to tsconfig.json: { "compileOnSave": false, "compilerOptions": { "baseUrl": "./", // ...some lin ...

Unable to store an empty array using mongoose

After attempting to save the mongoose model: steamBot.items = []; steamBot.save(function(){ callback(); }); However, if steamBot.items is not empty, mongoose will not save it. ...

What is the purpose of NPM including an empty "etc" directory and multiple command files during installation?

After updating or installing a package in my project, I've noticed that NPM is creating an empty etc folder and multiple .cmd files (refer to image below). Additionally, my package.json file is not being updated automatically anymore. I have to manual ...

Guide on using webpack to import jQuery

When using webpack, is it necessary to install the jquery file from npm, or can I simply require the downloaded file from the jquery website? directory app/ ./assets/javascripts/article/create/base.js ./assets/javascripts/lib/jquery-1.11.1.min.js webpack ...

Unable to instantiate the node redis client

I encountered an issue while trying to start my node application, and I received the following error message: TypeError: redisClient.on is not a function The problem seems to be related to the RedisClient module: const redisClient = require('re ...

Having trouble updating Angular CLI

It appears that I have successfully installed version 9 as per the usual installation process. npm install -g @angular/cli npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9abbca8acbcaaad99ebf7e1e1f7eb"> ...

Leveraging an Octave script within a Heroku application

Currently, I am facing an issue pushing my web application to Heroku that heavily relies on calling an Octave script. In order to carry out development and testing, I am utilizing an EC2 instance along with node.js. Octave has been installed on the EC2 ins ...

What is the best approach for managing authentication across different frameworks?

My Ruby web applications utilize OpenID for authentication and save session information in a cookie. To address some limitations with API and AJAX functionality within my Ruby frameworks, I have integrated node.js services into the mix. The concern arises ...

The excessive length of Windows file paths makes it impossible to install packages with Node npm

Situation Having trouble using gulp and related front-end tools in Windows-based development environments due to long file paths when copying files from nested node_modules folders. Looking for a practical solution to address this issue on Windows without ...

Utilize a script in the node package.json file to execute another script while including an additional parameter; for example, incorporating the mocha watcher

Is there a way to reuse a command already defined in a 'script' section of node's package.json? Let's consider the following practical example: Instead of having an additional -w flag on the watch script: "scripts": { "t ...

Incorporate the npm mqtt package into my Angular application

I'm trying to incorporate the package https://www.npmjs.com/package/mqtt#connect into my Angular project. Since it's not a standard Angular package, I'm unsure of what I need to include in the module and controller to make it function correc ...

"The Node.js program is unable to access the contents of the browser.js file when loaded in

After spending an unreasonable amount of time trying to debug this issue, I am still unable to resolve it. Currently, I am following a udemy tutorial where the instructor implements the same code provided below. However, despite my efforts, the code is not ...