bcrypt,将../node_modules/node-pre-gyp/lib/publish.js中的错误序列化:未找到模块:错误:无法解析'aws-sdk'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了bcrypt,将../node_modules/node-pre-gyp/lib/publish.js中的错误序列化:未找到模块:错误:无法解析'aws-sdk'相关的知识,希望对你有一定的参考价值。

使用expresswebpackbcryptsequelize节点模块时发生以下错误

(ERROR in ../node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'aws-sdk' and ERROR in ../node_modules/sequelize/lib/dialects/postgres/hstore.js
Module not found: Error: Can't resolve 'pg-hstore'
ERROR in ../node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'aws-sdk' in

ERROR in ../node_modules/node-pre-gyp/lib/info.js
Module not found: Error: Can't resolve 'aws-sdk' in '/my-work/react-ssr/node_modules/node-pre-gyp/lib'

ERROR in ../node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/react-ssr/node_modules/node-pre-gyp/lib'

ERROR in ../node_modules/sequelize/lib/dialects/postgres/hstore.js
Module not found: Error: Can't resolve 'pg-hstore' in '/Users/yogesh/Documents/my-work/blogpost-example-react-ssr/node_modules/sequelize/lib/dialects/postgres'
答案

它为我工作。我更改了webpack.server.config.js中的代码,您的代码可能是webpack.config.js或webpack.server.js ...等

.... webpack配置...

..from...

entry:...,
output: 
  path: path.join(__dirname, '..', 'build'),
  publicPath: '/',
  libraryTarget: "commonjs2"
,
target: 'node',

to

entry:...,
output: 
  path: path.join(__dirname, '..', 'build'),
  publicPath: '/',
  libraryTarget: "commonjs2"
,
target: 'node',

externals: 
  express: 'express',
  bcrypt:'bcrypt',
  sequelize:'sequelize',
,

只需添加下面的代码(其他模块相同)

externals: 
  express: 'express',
  bcrypt:'bcrypt',
  sequelize:'sequelize',
,

无需添加

var nodeExternals = require('webpack-node-externals');
externals: [nodeExternals()],

((我们可以避免再安装一个模块webpack-node-externals)

以上是关于bcrypt,将../node_modules/node-pre-gyp/lib/publish.js中的错误序列化:未找到模块:错误:无法解析'aws-sdk'的主要内容,如果未能解决你的问题,请参考以下文章

将用户密码从加盐 SHA1 升级到 bcrypt

[将Bcrypt与phpto哈希密码结合使用不起作用

将密码哈希从 md5 升级到 bcrypt [关闭]

Spring Security:无法将我的 UserDetailService 自动连接到 AuthenticationProvider 以进行 BCrypt 集成

Bcrypt 更长的密码

用 bcrypt (PHP) 比较两个哈希值