最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

无法在Visual Studio Code上为密码哈希函数安装bcrypt.ts

IT培训 admin 10浏览 0评论

无法在Visual Studio Code上为密码哈希函数安装bcrypt.ts

当前,我正在尝试基于npmjs的bcrypt指南实现哈希函数:

var bcrypt = require('bcrypt.ts');

// Sync - 10 rounds equal 10 hashes/sec
const saltRounds = 10;
const randomString = 'p4$$w0rD';

// Hash Password
var hash = bcrypt.hashSync(randomString, saltRounds);

console.log(hash);

在多次尝试使用“ npm install bcrypt”安装bcrypt模块之后,每次都会出现以下错误:

> [email protected] install C:\Users\Public\secrethash\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.

我已经在线搜索了此错误,但是没有找到一般的解决方法或解决方法。过了一段时间,我尝试重建npm,npm卸载bcrypt(并使用npm install bcrypt重新安装),修复了多个nody-gyp问题,等等。在全局安装并启用各种脚本执行之后,仍然出现先前的错误,但是bcrypt必须已成功安装:

PS C:\Users\Public\secrethash> npm install bcrypt

> [email protected] install C:\Users\Public\secrethash\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.
Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parallele Erstellung zu ermöglichen, müssen Sie den Schalter "/m" hinzufügen.
  nothing.vcxproj -> C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\\nothing.lib
  blowfish
  bcrypt
  bcrypt_node
  win_delay_load_hook
     Bibliothek "C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\bcrypt_lib.lib" und O
  bjekt "C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\bcrypt_lib.exp" werden erstel
  lt.
  bcrypt_lib.vcxproj -> C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\\bcrypt_lib.no
  de
  Copying C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\/bcrypt_lib.node to C:/Users
  /Public/secrethash/node_modules/bcrypt/lib/binding/napi-v3\bcrypt_lib.node
          1 Datei(en) kopiert.
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Public\secrethash\package.json'npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Public\secrethash\package.json'
npm WARN secrethash No description
npm WARN secrethash No repository field.
npm WARN secrethash No README data
npm WARN secrethash No license field.

+ [email protected]
updated 1 package and audited 441 packages in 11.015s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

[现在,我可以在项目的node_modules文件夹中找到一个bcrypt文件夹,但是(这正是我的问题所在的地方),当通过tsc和node执行typescript函数时,bycrypt.ts作为模块不能找到:

Error: Cannot find module 'bcrypt.ts'
Require stack:
- C:\Users\Public\secrethash\secret_hash.js
?[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)?[39m
?[90m    at Function.Module._load (internal/modules/cjs/loader.js:840:27)?[39m
?[90m    at Module.require (internal/modules/cjs/loader.js:1019:19)?[39m
?[90m    at require (internal/modules/cjs/helpers.js:77:18)?[39m
    at Object.<anonymous> (C:\Users\Public\secrethash\secret_hash.js:1:14)
?[90m    at Module._compile (internal/modules/cjs/loader.js:1133:30)?[39m
?[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)?[39m
?[90m    at Module.load (internal/modules/cjs/loader.js:977:32)?[39m
?[90m    at Function.Module._load (internal/modules/cjs/loader.js:877:14)?[39m
?[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)?[39m {
  code: ?[32m'MODULE_NOT_FOUND'?[39m,
  requireStack: [ ?[32m'C:\\Users\\Public\\secrethash\\secret_hash.js'?[39m ]
}

因此,我想问你们是否有人可以解释为什么仍然找不到该模块?也许在模块存储和工作目录方面我完全走错了(第一次使用VS代码和node.js / npm / typescript)。因此,我还上传了文件夹结构,以防止对模块必须放置在哪个目录中的任何误解。如果您需要更多信息,我们很乐意分享更多错误代码示例。

最好,谢谢!

Depository Folder Upper

Depository Folder Lower

回答如下:

我相信您提供的输出不是问题,它实际上是在通知您它决定退回到其他方法(而不是完全退出)。

虽然它已完成更新bcrypt:

+ [email protected]
updated 1 package and audited 441 packages in 11.015s

此外,bcrypt.ts不存在,在引用库时也不需要添加.ts,即使那样,也不需要为.ts或[添加文件扩展名C0]。

您使用TypeScript吗?在我看来,您正在使用Node.js,因此.js不需要/不兼容。

无法在Visual Studio Code上为密码哈希函数安装bcrypt.ts

当前,我正在尝试基于npmjs的bcrypt指南实现哈希函数:

var bcrypt = require('bcrypt.ts');

// Sync - 10 rounds equal 10 hashes/sec
const saltRounds = 10;
const randomString = 'p4$$w0rD';

// Hash Password
var hash = bcrypt.hashSync(randomString, saltRounds);

console.log(hash);

在多次尝试使用“ npm install bcrypt”安装bcrypt模块之后,每次都会出现以下错误:

> [email protected] install C:\Users\Public\secrethash\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.

我已经在线搜索了此错误,但是没有找到一般的解决方法或解决方法。过了一段时间,我尝试重建npm,npm卸载bcrypt(并使用npm install bcrypt重新安装),修复了多个nody-gyp问题,等等。在全局安装并启用各种脚本执行之后,仍然出现先前的错误,但是bcrypt必须已成功安装:

PS C:\Users\Public\secrethash> npm install bcrypt

> [email protected] install C:\Users\Public\secrethash\node_modules\bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error Remote end closed socket abruptly.
Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parallele Erstellung zu ermöglichen, müssen Sie den Schalter "/m" hinzufügen.
  nothing.vcxproj -> C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\\nothing.lib
  blowfish
  bcrypt
  bcrypt_node
  win_delay_load_hook
     Bibliothek "C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\bcrypt_lib.lib" und O
  bjekt "C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\bcrypt_lib.exp" werden erstel
  lt.
  bcrypt_lib.vcxproj -> C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\\bcrypt_lib.no
  de
  Copying C:\Users\Public\secrethash\node_modules\bcrypt\build\Release\/bcrypt_lib.node to C:/Users
  /Public/secrethash/node_modules/bcrypt/lib/binding/napi-v3\bcrypt_lib.node
          1 Datei(en) kopiert.
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Public\secrethash\package.json'npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Public\secrethash\package.json'
npm WARN secrethash No description
npm WARN secrethash No repository field.
npm WARN secrethash No README data
npm WARN secrethash No license field.

+ [email protected]
updated 1 package and audited 441 packages in 11.015s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

[现在,我可以在项目的node_modules文件夹中找到一个bcrypt文件夹,但是(这正是我的问题所在的地方),当通过tsc和node执行typescript函数时,bycrypt.ts作为模块不能找到:

Error: Cannot find module 'bcrypt.ts'
Require stack:
- C:\Users\Public\secrethash\secret_hash.js
?[90m    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)?[39m
?[90m    at Function.Module._load (internal/modules/cjs/loader.js:840:27)?[39m
?[90m    at Module.require (internal/modules/cjs/loader.js:1019:19)?[39m
?[90m    at require (internal/modules/cjs/helpers.js:77:18)?[39m
    at Object.<anonymous> (C:\Users\Public\secrethash\secret_hash.js:1:14)
?[90m    at Module._compile (internal/modules/cjs/loader.js:1133:30)?[39m
?[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)?[39m
?[90m    at Module.load (internal/modules/cjs/loader.js:977:32)?[39m
?[90m    at Function.Module._load (internal/modules/cjs/loader.js:877:14)?[39m
?[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)?[39m {
  code: ?[32m'MODULE_NOT_FOUND'?[39m,
  requireStack: [ ?[32m'C:\\Users\\Public\\secrethash\\secret_hash.js'?[39m ]
}

因此,我想问你们是否有人可以解释为什么仍然找不到该模块?也许在模块存储和工作目录方面我完全走错了(第一次使用VS代码和node.js / npm / typescript)。因此,我还上传了文件夹结构,以防止对模块必须放置在哪个目录中的任何误解。如果您需要更多信息,我们很乐意分享更多错误代码示例。

最好,谢谢!

Depository Folder Upper

Depository Folder Lower

回答如下:

我相信您提供的输出不是问题,它实际上是在通知您它决定退回到其他方法(而不是完全退出)。

虽然它已完成更新bcrypt:

+ [email protected]
updated 1 package and audited 441 packages in 11.015s

此外,bcrypt.ts不存在,在引用库时也不需要添加.ts,即使那样,也不需要为.ts或[添加文件扩展名C0]。

您使用TypeScript吗?在我看来,您正在使用Node.js,因此.js不需要/不兼容。

发布评论

评论列表 (0)

  1. 暂无评论