Having trouble removing symbolic links even after executing npm link

After setting up some executable commands in my project and defining them in the bin property of the package.json, I performed a npm link. This created symlinks in the .nvm/versions/node/v16.13.0/bin directory (since I am using nvm).

However, when I made updates to my scripts (cmd1.js / cmd2.js), the changes were not reflected when running cmd1 or cmd2. It seems like I need to remove the executables from the .nvm/versions/node/v16.13.0/bin directory and then run npm link again, which is quite inconvenient. Additionally, attempting to use npm unlink results in an error message saying "Must provide a package name to remove", even though I am not trying to unlink another package.

Are there any solutions to this issue?

Answer №1

Dealing with a similar issue led me to discover the following helpful post:

To remove the link, I executed the following command:

$ npm uninstall -g

Answer №2

To efficiently solve this issue, I followed these steps in order:

  1. Firstly, check the location of the global node_modules directory:
$ npm root -g
/Users/username/.nvm/versions/node/v18.14.2/lib/node_modules
  1. Go to that directory and identify symlinks to be removed:
$ cd /Users/username/.nvm/versions/node/v18.14.2/lib/node_modules

$ ls -al

total 0
drwxr-xr-x  10 username  staff  320 28 Mar 08:27 .
drwxr-xr-x   4 username  staff  128 20 Feb 20:05 ..
drwxr-xr-x   2 username  staff   64 28 Mar 08:26 @yolo
drwxr-xr-x   8 username  staff  256 20 Feb 20:05 something
drwxr-xr-x  10 username  staff  320 27 Mar 11:24 eslint
lrwxr-xr-x   1 username  staff   53 27 Mar 12:58 forget-me-soon -> ../../../../../../dev/uniquename/some-test/botched-thing
lrwxr-xr-x   1 username  staff   45 27 Mar 12:30 some-bad-test -> ../../../../../../dev/uniquename/some-bad-test
drwxr-xr-x  12 username  staff  384 20 Feb 20:05 npm
lrwxr-xr-x   1 username  staff   44 15 Mar 11:24 botched-config -> ../../../../../../dev/uniquename/botched-config
lrwxr-xr-x   1 username  staff   45 27 Mar 12:29 steven-segal -> ../../../../../../dev/uniquename/some-bad-test
  1. Delete the unnecessary symlinks:
$ rm -rf forget-me-soon
$ rm -rf some-bad-test
$ rm -rf botched-config
$ rm -rf steven-segal

$ ls -al
# nothing unwanted remains
  1. Verify npm's recognition of linked modules:
$ npm ls -g --depth=0 --link=true
/Users/username/.nvm/versions/node/v18.14.2/lib
└── (empty)

Answer №3

If you're using a Windows operating system, you also have the option to remove the directory by following these steps:

C:\Users\username\AppData\Roaming\npm\node_modules

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

Executing Java program from a Node.js application

After researching, I discovered a few methods for running `java` files within a `node.js` application. One option is to spawn a child process: (where the java code is contained with dependencies in an executable `jar`). var exec = require('child_proc ...

Consolidate various arrays of objects while eliminating duplicate items based on an optional property

Imagine having multiple arrays like these: const arr1 = [ { "id": "1", "type": "sales" }, { "id": "2", "type": "finance" } ] const arr2 = [ { "type": "s ...

Optimizing SEO for SPA (single page application) with dynamically generated content through node.js + express.js on the backend server

My client-side code is a unique single-page app created using knockout.js. It has its own routing system, which poses a challenge when the Google crawler bot attempts to access links that are not directly requesting new pages from the backend but are rathe ...

Is there a way for me to incorporate a feature that verifies whether an email address is already registered before allowing the person to sign up?

I am currently working with Node.js, express.js, mongoose, and pug to develop a registration/login system. I have successfully stored the name and email in a mongoose database with specified schema for these fields. The data is sent from a pug page via a p ...

Tips for utilizing date objects instead of date 'strings' while still obtaining the desired outcome

Below is a schema that I am working with: var MySchema = new Schema ({ event: { full: String, date: String, name: String, } }); To illustrate, here are some examples of the values: event.date = '16/02/20 ...

Tips for connecting a Django API project with a nodejs and react frontend

I'm currently working on a Django API project and I am considering incorporating Node.js into the mix. Additionally, I am interested in using React for the frontend of the application. Is this combination of technologies feasible? Would it be advisabl ...

Node version conflicts on macOS

Recently, I decided to switch over to Angular6 for my projects, but encountered an error message stating that my node version was outdated (lower than 8.9). After attempting to resolve this issue, it appears that my system is running two different versions ...

Once the post has been saved to the database, how can I redirect to a different EJS page?

Is there a way to load another page after submitting a post in node.js with ejs? //router function router() { ticketRouter.route("/create/submit") // connected to submit from specific ejs file .post(dataControllerThatHandlesSubmission) // functio ...

Utilizing Node/NPM to successfully pass arguments during the execution of a .sh file

Utilizing the script block in package.json, I have set up a call to the postinstall.sh script to run immediately after both yarn install and yarn install --production. The postinstall.sh script includes some private npm packages, and we only want to downl ...

What are the best ways to store internal files in node.js for faster access?

I have been utilizing routing functions like the one mentioned below to replicate the overall design of my website (A.jade): exports.overview = function(req, res, next) { res.render('A', { main: jade.renderFile('./views/B.jade' ...

Having trouble accessing stored images in node.js/express

After saving some images in the directory myproject/controllers/upload, I included app.use(express.static(__dirname + '/controllers/upload')); in my app.js. However, when trying to access the image directly in the browser using: http://localhost ...

To combine arrays A and B within a React useState object, simply pass them as arguments when initializing the state

Currently, I am working on integrating infinite scroll functionality in React, where I need to fetch data from a backend API for loading content on the next page. The challenge I'm facing is that my state is set as an object using useState, and I need ...

Screen content of a post request in Node.js

Can this code in node.js + express be simplified? // Code snippet for registering a new participant app.post('/api/participant', function (req, res, next) { var data = req.body; // Ensure only specific fields are uploaded var parti ...

The bond between TypeORM and express

I am working on establishing Many-to-One and One-to-Many relationships using TypeORM and MySQL with Express. The database consists of two tables: post and user. Each user can have multiple posts, while each post belongs to only one user. I want to utilize ...

Choosing between creating a class with a shared instance or not

I'm curious if my class is shared across instances: for example, I have a route that looks like this: /student/:id When this route triggers the controller (simplified version): module.exports = RecalculateStudents; const recalculateActiveStudent ...

I created a Vue object, but I seem to have misplaced it

I have a question about my code. I am trying to run Webpack and turn my main.js file into stem.js. Unfortunately, it's not working as expected. My app seems to be missing. Can anyone help me troubleshoot this issue? ...

Fixing problems encountered when asynchronously gunzipping an already read file in Node.js

As a newcomer to the world of node.js and asynchronous programming, I have successfully used promises to read files with fs readFile, but I am struggling with getting zlib Gunzip to function as expected in my Coffeescript code: promisifyRun(fs, 'r ...

Solving conflicts in resolving Bower packages

I've encountered an issue with my app that utilizes jQuery version 1.11.1. After installing a typeahead component as a Bower package, it appears to be dependent on a different version of jQuery (v 1.9). The conflicting dependencies have left me feeli ...

The Express server's `GET` request at the root does not seem

When I access localhost:8080/chat?k=1&d=1, the console displays "CHAT PAGE" and everything works correctly. However, when I try to visit localhost:8080, the root event does not display "INDEX PAGE" as expected. Instead, it automatically retrieves ind ...

Guidelines for managing UnprocessedItems with the AWS JavaScript SDK for dynamoDB

Currently, I'm facing an issue while attempting to utilize an AWS Lambda function for handling events from SendGrid. The event is expected to be in the form of an array containing a variable number of JSON objects, each representing a specific event. ...