当我在nodejs目录中运行升级时,显示以下错误:
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.
+ lodash@4.17.21
updated 1 package and audited 1 package in 0.384s
found 0 vulnerabilities
当我在lodash目录中运行升级时,显示以下错误:
/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
当我在其他目录中运行升级命令时,我发现lodash安装在
/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/
我不知道nodejs和lodash。
有谁知道如何更新/usr/share/nodejs
目录下的lodash吗?我不知道是否需要在这里更新。当我使用npm list lodash时,只有这个目录显示版本信息。
另外,我不知道lodash不在node_modules目录中,因为我没有安装它,我不知道如何处理它
nodejs目录下有哪些lodash.* 文件,它们的功能是什么?它们都是lodash吗?
2条答案
按热度按时间xlpyo6sf1#
我认为你安装了全局软件包。一旦尝试:
npm update -g <package_name>
0aydgbwb2#
我的package.json文件和lodash版本
要更新lodash版本,只需使用命令
npm install lodash@<lodash_version>
例如:
npm install lodash@4.17.21
使用此命令后轻松更新lodash版本