所以我一直在尝试运行这个网络应用程序,起初它显示
(node:12960) 警告:要加载 ES 模块,请在 package.json 中设置 "type": "module" 或使用 .mjs 扩展名。
C:\Users\J\react-messenger\stream-chat-boilerplate-api\src\index.js:1
从 'dotenv' 导入 dotenv; ^^^^^^
语法错误:不能在模块外使用导入语句
然后我去把 set the type: module 放在 package.json 中,但它给了我这个错误
参考错误:模块未定义
at file:///C:/Users/J/react-messenger/stream-chat-boilerplate-api/src/index.js:38:1
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import dotenv from 'dotenv';
dotenv.config();
import fs from 'fs';
import path from 'path';
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import helmet from 'helmet';
import compression from 'compression';
const api = express();
api.use(cors());
api.use(compression());
api.use(helmet());
api.use(bodyParser.urlencoded({ extended: true }));
api.use(bodyParser.json());
api.listen(process.env.PORT, error => { …Run Code Online (Sandbox Code Playgroud) 我有一个托管在循环上的 NodeJs API。早些时候一切工作正常,但我用尽了我的免费层 API 请求,我的应用程序被暂停,然后不得不升级。从那时起我就一直遇到这个错误
MongoDB connection error: MongoNetworkError: 805C21D67D7F0000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:1586:SSL alert number 80
at connectionFailureError (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:367:20)
at TLSSocket.<anonymous> (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:290:22)
at Object.onceWrapper (node:events:629:26)
at TLSSocket.emit (node:events:514:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
cause: [Error: 805C21D67D7F0000:error:0A000438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:ssl/record/rec_layer_s3.c:1586:SSL alert number 80
] {
library: 'SSL routines',
reason: 'tlsv1 alert internal error',
code: 'ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR'
},
connectionGeneration: 2,
[Symbol(errorLabels)]: Set(1) { 'ResetPool' }
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一切,我以为我的 mongo 免费层已经用完了。我升级了,没用。我更新了我的猫鼬包,我尝试在网上搜索但找不到任何东西。这就是我在index.js中连接到数据库的方式 //在监听之前连接到数据库
connectDB().then(() => {
app.listen(PORT, () => …Run Code Online (Sandbox Code Playgroud) 我不知道为什么我会收到这个错误,我试过在线搜索,我看到了一些我尝试过但错误没有清除的建议。请有没有人知道我做错了什么。这是我的代码:
import React from 'react';
import { BrowseRouter as Router, Route } from 'react-router-dom';
import Join from './components/Join';
import Chat from './components/Chat';
const App = () => (
<Router>
<Route path="/" exact component={Join} />
<Route path="/chat" exact component={Chat} />
</Router>
);
export default App;
Run Code Online (Sandbox Code Playgroud) 我目前在一个 nft 市场工作,希望对每笔销售收取 2.5% 的费用。我已经在线阅读和研究了如何计算坚固性百分比,并在这方面取得了成功,但问题是结果是一个巨大的数字,即 2.5 * 150/100 应该返回 3.75 但我得到这个数字: 3750000000000000000000000000000000000
我的测试
const auctionPrice = ethers.utils.parseUnits("1", "ether");
const [_, userAddress] = await ethers.getSigners();
let fee = (2.5 * auctionPrice) / 100;
const commission = ethers.utils.parseUnits(fee.toString(), "ether");
let commissionValue = commission.toString();
console.log(commission.toString());
console.log(fee);
await market
.connect(userAddress)
.createMarketSale(nftContractAddress, 1, commissionValue, {
value: auctionPrice,
});
Run Code Online (Sandbox Code Playgroud)
结果
250000000000000000000000000000000
1 failing
1) NFTMarket
Should create and execute market sales:
Error: Transaction reverted: function call failed to execute
at NFTMarket.createMarketSale (contracts/NFTMarket.sol:165)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at …Run Code Online (Sandbox Code Playgroud) javascript ×2
node.js ×2
reactjs ×2
cyclic ×1
hardhat ×1
mongodb ×1
mongoose ×1
nft ×1
node-modules ×1
solidity ×1
syntax-error ×1