[英]Unable to install node_modules in Express js
I'm try to install node_modules
from package.json file but i got error.我尝试从 package.json 文件安装node_modules
,但出现错误。
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: nfttoken@1.0.0
npm ERR! Found: mongoose@5.13.15
npm ERR! node_modules/mongoose
npm ERR! mongoose@"^5.13.7" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mongoose@"^4.1.12" from mongoose-auto-increment@5.0.1
npm ERR! node_modules/mongoose-auto-increment
npm ERR! mongoose-auto-increment@"^5.0.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
My package json dependencies我的 package json 依赖项
"dependencies": {
"express": "^4.17.1",
"express-fileupload": "^1.2.1",
"express-validator": "^6.12.1",
"mongoose": "^5.13.7",
"mongoose-auto-increment": "^5.0.1",
"mongoose-sequence": "^5.3.1",
"xml-formatter": "^2.6.1",
"xml2json": "^0.12.0"
}
how can i solve this.我该如何解决这个问题。
EDIT:编辑:
I just run npm install
i got below errors.我刚刚运行npm install
时出现以下错误。
npm ERR! code 1
npm ERR! path <PROJECT-PATH>backend/node_modules/node-expat
npm ERR! command failed
npm ERR! command sh /tmp/install-1e860795.sh
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.0.0
npm ERR! gyp info using node@16.17.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '<PROJECT-PATH>backend/node_modules/node-expat/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '<HOME-PATH>.cache/node-gyp/16.17.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=<HOME-PATH>.cache/node-gyp/16.17.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=<HOME-PATH>.cache/node-gyp/16.17.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=<PROJECT-PATH>backend/node_modules/node-expat',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: not found: make
npm ERR! gyp ERR! stack at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:10:17)
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:57:18
npm ERR! gyp ERR! stack at new Promise (<anonymous>)
npm ERR! gyp ERR! stack at step (/usr/lib/node_modules/npm/node_modules/which/which.js:54:21)
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:71:22
npm ERR! gyp ERR! stack at new Promise (<anonymous>)
npm ERR! gyp ERR! stack at subStep (/usr/lib/node_modules/npm/node_modules/which/which.js:69:33)
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:80:22
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! System Linux 5.15.0-46-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd <PROJECT-PATH>backend/node_modules/node-expat
npm ERR! gyp ERR! node -v v16.17.0
npm ERR! gyp ERR! node-gyp -v v9.0.0
npm ERR! gyp ERR! not ok
Did you read the error?你读过错误吗? That mongoose-auto-increment
library requires version 4 of mongoose
, but you have mongoose
5.该 mongoose mongoose-auto-increment
库需要mongoose
版本 4,但您拥有mongoose
5。
You can see if things might work by adding one of the options suggested in the error, ie npm i --legacy-peer-deps
or npm i --force
, or you might want to look for a newer versionf of mongoose-auto-increment
that claims support for Mongoose 5 (though that seems to be unlikely, since that last version of that library was released 7 years ago).您可以通过添加错误中建议的选项之一来查看是否可行,即npm i --legacy-peer-deps
或npm i --force
,或者您可能想要寻找更新版本的 mongoose mongoose-auto-increment
声称支持 Mongoose 5 的mongoose-auto-increment
(尽管这似乎不太可能,因为该库的最后一个版本是 7 年前发布的)。
Would you please remove node_modules folder from the root of your project?请您从项目的根目录中删除 node_modules 文件夹吗?
Then try to run然后尝试运行
npm install npm安装
If this is still the problem.如果这仍然是问题。 Try removing node_modules folder again and run尝试再次删除 node_modules 文件夹并运行
npm i --legacy-peer-deps npm i --legacy-peer-deps
If this still not works, try to downgrade/upgrade the package mongoose-auto-increment如果这仍然不起作用,请尝试降级/升级 package mongoose-auto-increment
I hope those steps will work.我希望这些步骤能够奏效。 Let me know this problem still persits.让我知道这个问题仍然存在。
For anyone else facing the same issue.对于面临同样问题的任何其他人。
One(or more) dependency in the package.json is not compatible with the latest version of nodejs. package.json 中的一个(或多个)依赖与最新版本的 nodejs 不兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.