When I run the upgrade in the nodejs directories, the following error is displayed:
sudo npm install lodash@latest
npm WARN saveError ENOENT: no such file or directory, open '/usr/share/nodejs/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/usr/share/nodejs/package.json'
npm WARN nodejs No description
npm WARN nodejs No repository field.
npm WARN nodejs No README data
npm WARN nodejs No license field.
+ [email protected]
updated 1 package and audited 1 package in 0.384s
found 0 vulnerabilities
When I run the upgrade in the lodash directories, the following error is displayed:
/usr/share/nodejs/lodash$ sudo npm install lodash@latest
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "lodash" under a package
npm ERR! also called "lodash". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR!
npm ERR! For more information, see:
npm ERR! <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-03-20T03_12_36_652Z-debug.log
When I ran the upgrade command in other directories, I found that lodash was installed in
/home/ubuntu/node_modules/,
/node_modules$ll
drwxrwxr -x 5 ubuntu ubuntu 4096 Mar 20 03:11 ./
dr-xr-xr-x 23 ubuntu ubuntu 4096 Mar 20 03:11 ../
drwxrwxr-x 2 ubuntu ubuntu 4096 Feb 28 2020 .bin/
drwxr-xr-x 3 ubuntu ubuntu 20480 Mar 20 03:11 lodash/
I don’t know nodejs and lodash.
Does anyone know how to update lodash in the /usr/share/nodejs
directory? I don’t know if it needs to be updated here. When I use npm list lodash, only this directory shows the version information.
Also, I don’t know that lodash is not in the node_modules directory, because I didn’t install it, and I don’t know what to do with it
What are the many lodash.* files under the nodejs directory, and what are their functions? Are they all lodash?
2
Answers
I am thinking that you installed package globally.
Once try :
npm update -g <package_name>
my package.json file and lodash version
To update lodash version simply use command
npm install lodash@<lodash_version>
for example :
npm install [email protected]
after use this command update Easily lodash version