javascript React vite应用程序显示错误:No loader is configured for“.html”files:../server/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html

qvtsj1bj  于 4个月前  发布在  Java
关注(0)|答案(1)|浏览(192)

React vite web app显示错误错误[ERROR] No loader is configured for“.html”files:../server/node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html

../server/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:86:21:
  86 │       return require('./' + command)(self, argvx, callback);
     ╵                      ~~~~~~~~~~~~~~

字符串
[错误]无法解析“mock-aws-s3”

../server/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
  43 │     const AWSMock = require('mock-aws-s3');
     ╵                             ~~~~~~~~~~~~~


您可以将路径“mock-aws-s3”标记为external,以将其从bundle中排除,这将删除此错误并将未解析的路径保留在bundle中。您还可以使用try/catch块来包围此“require”调用,以在运行时而不是运行时处理此失败。
[错误]无法解析“aws-sdk”

../server/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:22:
  76 │   const AWS = require('aws-sdk');
     ╵                       ~~~~~~~~~


您可以将路径“aws-sdk”标记为external以将其从bundle中排除,这将删除此错误并将未解析的路径保留在bundle中。您还可以在此“require”调用周围使用try/catch块,以在运行时而不是在运行时处理此失败。
错误[ERROR]无法解析“nock”

../server/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
  112 │   const nock = require('nock');
      ╵                        ~~~~~~


您可以将路径“nock”标记为external,以将其从bundle中排除,这将删除此错误并将未解析的路径保留在bundle中。您还可以使用try/catch块来包围此“require”调用,以在运行时而不是运行时处理此失败。
这些是我运行React Vite应用程序时发生的错误

GET http://localhost:5173/ net::ERR_CONNECTION_REFUSED

  • 已安装所有相关依赖和包,但错误仍然存在。**
sr4lhrrt

sr4lhrrt1#

在安装并导入bcrypt到我的Remix应用程序中后,我也遇到了同样的错误,使用Vite。导致错误的依赖项被列为@mapbox/node-pre-gyp的开发依赖项,但它们(可能是由于糟糕的设计)包含在包的调用堆栈中。
In this thread,有多个人有同样的问题,没有从作者的回应.有很多不同的解决办法,也有,我倾向于使用本机节点:加密散列和盐我的密码,因为这是我用bcrypt做的.
这里也有一些关于将bcrypt替换为node的讨论:Link
这里有一个代码片段:

const {
    scryptSync,
    randomBytes
} = await import('crypto');

if (salted) {
    const hash = scryptSync(password, salted, 64).toString('hex');
    return new HashAndSalt(hash, salted);
} else {
    const salt = randomBytes(32).toString("hex");
    const hash = await scryptSync(password, salt, 64).toString('hex');
    return new HashAndSalt(hash, salt);
}

字符串

相关问题