我删除了我的node_modules文件夹,以修复以前的错误,现在我被困在另一个和另一个,我甚至忘记了最初的错误。每次我尝试运行npm install或尝试安装bcrypt时,我都会得到相同的错误。
错误:
npm ERR! code 1
npm ERR! path C:UsersuserDocumentsreact-nativereinnode_modulesbcrypt
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
npm ERR! node:internal/modules/cjs/loader:361
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Cannot find module 'C:UsersuserDocumentsreact-nativereinnode_modulesset-blockingindex.js'. Please verify that the package.json has a valid "main" entry
npm ERR! at tryPackage (node:internal/modules/cjs/loader:353:19)
npm ERR! at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
npm ERR! at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
npm ERR! at Function.Module._load (node:internal/modules/cjs/loader:778:27)
npm ERR! at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR! at require (node:internal/modules/cjs/helpers:102:18)
npm ERR! at Object.<anonymous> (C:UsersuserDocumentsreact-nativereinnode_modulesnpmloglog.js:8:19)
npm ERR! at Module._compile (node:internal/modules/cjs/loader:1101:14)
npm ERR! at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm ERR! at Module.load (node:internal/modules/cjs/loader:981:32) {
npm ERR! code: 'MODULE_NOT_FOUND',
npm ERR! path: 'C:\Users\user\Documents\react-native\rein\node_modules\set-blocking\package.json',
npm ERR! requestPath: 'set-blocking'
npm ERR! }
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersuserAppDataLocalnpm-cache_logs2022-06-28T19_34_30_960Z-debug-0.log
我已尝试删除包锁。并在包中指定一个主条目。
我被告知在安装bcrypt之前运行这个代码npm install --global --production windows-build-tools
根据他们的[github wiki][1]但每次我尝试安装它,(我以admin身份运行powershell)它永远不会完成。它只写了completed in 28
,没有结束。我现在被困住了,很沮丧。我同样试图安装set-blocking
,即使我不知道它是什么,但我看到错误说模块丢失,所以我尝试安装它,但仍然没有工作。给了我相同的错误说但这一次不同的模块是失踪。
npm ERR! code 7
npm ERR! path C:UsersuserDocumentsreact-nativereinnode_modulesbcrypt
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c node-pre-gyp install --fallback-to-build
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.9
npm ERR! node-pre-gyp info using node@16.13.1 | win32 | x64
npm ERR! node-pre-gyp ERR! UNCAUGHT EXCEPTION
npm ERR! node-pre-gyp ERR! stack Error: Cannot find module 'C:UsersuserDocumentsreact-nativereinnode_moduleswhatwg-urllibpublic-api.js'. Please verify that the package.json has a valid "main" entry
npm ERR! node-pre-gyp ERR! stack at tryPackage (node:internal/modules/cjs/loader:353:19)
npm ERR! node-pre-gyp ERR! stack at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
npm ERR! node-pre-gyp ERR! stack at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
npm ERR! node-pre-gyp ERR! stack at Module.require (node:internal/modules/cjs/loader:1005:19)
npm ERR! node-pre-gyp ERR! stack at require (node:internal/modules/cjs/helpers:102:18)
npm ERR! node-pre-gyp ERR! stack at Object.<anonymous> (C:UsersuserDocumentsreact-nativereinnode_modules@mapboxnode-pre-gypnode_modulesnode-fetchlibindex.js:10:33)
npm ERR! node-pre-gyp ERR! stack at Module._compile (node:internal/modules/cjs/loader:1101:14)
npm ERR! node-pre-gyp ERR! stack at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm ERR! node-pre-gyp ERR! stack at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.18362
npm ERR! node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\user\Documents\react-native\rein\node_modules\@mapbox\node-pre-gyp\bin\node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd C:UsersuserDocumentsreact-nativereinnode_modulesbcrypt
npm ERR! node-pre-gyp ERR! node -v v16.13.1
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.9
npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersuserAppDataLocalnpm-cache_logs2022-06-28T18_28_13_176Z-debug-0.log
现在我很困惑,它变成了一个痛苦的屁股。请有人知道我能做什么,因为我已经尝试了所有的选择,我可以。[1]: https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions microsoft windows
我有同样的问题,并通过将package.json
文件中的bcrypt
版本手动更改为"bcrypt": "^5.0.1",
来解决。
然后再次运行npm i
,不会出现任何错误。
清理NPM缓存
npm cache clean --force
然后安装你的包
make in the package "type: module">