简体   繁体   中英

Npm install failing because of bcrypt error

I deleted my node_modules folder in order to fix a previous error and now I'm stuck in another one and another one, I've even forgotten the initial error. Every time I try to run npm install or try to install bcrypt I get the same error.

Error:

    npm ERR! code 1
npm ERR! path C:\Users\user\Documents\react-native\rein\node_modules\bcrypt
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.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:\Users\user\Documents\react-native\rein\node_modules\set-blocking\index.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:\Users\user\Documents\react-native\rein\node_modules\npmlog\log.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:\Users\user\AppData\Local\npm-cache\_logs\2022-06-28T19_34_30_960Z-debug-0.log

I have tried deleting my package-lock.json and specifying a main entry in my package.json but nothing yet.

I was told to run this code npm install --global --production windows-build-tools before installing bcrypt according to their [github wiki][1] but everytime I try to install it, (I run powershell as admin) It never completes. It just says completed in 28 and never finishes. I am stuck now and frustrated. I equally tried to install set-blocking even though I have no idea what it was but I saw the error say the module was missing so I tried installing it but still didn't work. Gave me the same exact error but this time said a different module was missing.

npm ERR! code 7
npm ERR! path C:\Users\user\Documents\react-native\rein\node_modules\bcrypt
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.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:\Users\user\Documents\react-native\rein\node_modules\whatwg-url\lib\public-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:\Users\user\Documents\react-native\rein\node_modules\@mapbox\node-pre-gyp\node_modules\node-fetch\lib\index.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:\Users\user\Documents\react-native\rein\node_modules\bcrypt
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:\Users\user\AppData\Local\npm-cache\_logs\2022-06-28T18_28_13_176Z-debug-0.log

Now I'm confused and it's becoming a pain in the ass. Please does anyone have any idea what I can do as I've tried every option I can. [1]: https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#microsoft-windows

clean your npm cache

npm cache clean --force

then install your packages

make in the package "type: module"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM