Node module update issue

Hi
I'm trying to update node-red-node-email from Node-red's manage pallete section, but it throws error that the module is not installed locally.
So after reading forums I found out that I need to see where my module is initially installed and for that I ran the command npm ls -g node-red-node-email which returned the following result:

Screenshot%20from%202018-09-03%2012-01-30

However, when I install the module globally (as per forums instructions) with the command sudo npm ls -g node-red-node-email and re-run the npm ls -g node-red-node-email command, so the hierarchy ends up like this:

/usr/lib
├─┬ node-red@0.19.2
│ └── node-red-node-email@0.1.29 
└── node-red-node-email@1.0.1 

So, my question is, why do I end up with two different instances of same module? and where exactly is ver 1.0.1 residing?

Also, how can I fix this? (preferably by removing the old version)

Thanks

Just answered this in another thread

It is a good idea to read the install notes for a node - see the last line.

Install

Version 0.x of this node is usually installed by default by Node-RED. To install version 1.x you need to uninstall the existing version.

    sudo npm uninstall -g node-red-node-email

Then run the following command in your Node-RED user directory - typically ~/.node-red

    npm i node-red-node-email

Note : this installs the new version locally rather than globally. This can then be managed by the palette manager.

Uninstalling the module with the command leaves back to the following state:

Screenshot%20from%202018-09-03%2012-01-30

Seems like the command only removes node-red-node-email@1.0.1, though node-red-node-email@0.1.29 module is still present.

that’s the version of Node-RED (0.19.2) not any email node

my bad, I fixed the typo.
how can I uninstall node-red-node-email@0.1.29?

I had to remove the folder manually:

sudo rm -r /usr/lib/node_modules/node-red/node_modules/node-red-node-email

where my npm root is:

npm root -g
/usr/lib/node_modules

Is it safe to delete the folder rather than uninstalling the module properly?
I mean, doesn't npm keep track of modules installed and later complain when missing without uninstalling?

Well I first did the uninstall but the folder hasn't been removed!

Unfortunately, in my case, the folder isn't empty.

which folder?

/usr/lib/node_modules/node-red/node_modules/node-red-node-email

Ok, here is what I did:

sudo npm uninstall -g node-red-node-email

sudo rm -r /usr/lib/node_modules/node-red/node_modules/node-red-node-email

cd ~/.node-red

npm i node-red-node-email

this way the node-red-node-email is installed in the .node-red folder.

I'm not fully convinced with deleting the module folder part. This is what I did:
sudo npm uninstall -g node-red-node-email
and it outputs:
up to date in 0.038s
which means uninstall did nothing.
later I called:
sudo npm ls -g node-red-node-email
and it outputs:

/usr/lib
└─┬ node-red@0.19.2
  └── node-red-node-email@0.1.29

then I removed the module folder as you suggested:
sudo rm -r /usr/lib/node_modules/node-red/node_modules/node-red-node-email
and re-printed the module status, and this time I get the following:
Screenshot%20from%202018-09-03%2013-53-39

As I pointed earlier, node-red keeps track of installed modules and deleting the module-folder just like that doesn't seem the right way.

I know that, probably because of the node-red package.json dependency
"node-red-node-email": "0.1.*",

But if you go on installing the node locally in ./node-red and restart node-red, what happens?

Installing module:

waqas@aslam:~/.node-red$ npm i node-red-node-email
npm WARN deprecated mailparser@0.6.2: Mailparser versions older than v2.3.0 are deprecated
npm WARN deprecated mimelib@0.3.1: This project is unmaintained
+ node-red-node-email@1.0.1
added 19 packages from 12 contributors in 1.47s

Showing local listing:

waqas@aslam:~/.node-red$ sudo npm ls node-red-node-email
node-red-project@0.0.1 /home/waslam/.node-red
└── node-red-node-email@1.0.1 

Showing global listing:

waqas@aslam:~/.node-red$ sudo npm ls -g node-red-node-email
/usr/lib
└─┬ node-red@0.19.2
  └── UNMET DEPENDENCY node-red-node-email@0.1.*

npm ERR! missing: node-red-node-email@0.1.*, required by node-red@0.19.2

Looks like my global listing is messed up.

did you restart node-red and check the node-red-node-email version?

It looks fine in node-red UI with correct version.

Seems like I've fixed the global listing issue by removing

"node-red-node-email": "0.1.*",

from package.json file in /usr/lib/node_modules/node-red

and now this is what I get when print global listing:

/usr/lib
└── (empty)

which means there's no such package installed globally.

I did also remove the dependency but I think we should ask @knolleary or @dceejay for the best praxis.
Maybe update package.json?

I wonder if you need to do a remove not uninstall

I'm not sure I undestand you.
I just did an uninstall following the doc but actually it doesn't uninstall (probably because it's installed in the node-red path) so I've removed the folder with all the included files manually.