小编Rah*_*hul的帖子

什么是 jsconfig.json?

如果我在 Internet 上搜索相同的问题,那么我\xe2\x80\x99 将仅获得 Visual Studio Code 网站和一些实现它的博客的链接。

\n

我想知道这是jsconfig.json特定于 Visual Studio Code 还是javascript/webpack

\n

如果我们将应用程序部署在AWSHeroku上会发生什么等上会发生什么,我们需要做出改变吗?

\n

javascript node.js visual-studio-code

66
推荐指数
1
解决办法
6万
查看次数

无法在 mac M1 芯片设备上安装 node@10

系统

在此输入图像描述

我有一个需要 node@10 才能运行的项目。我使用https://brew.sh安装node@10。

我使用以下命令安装node@10

brew install --build-from-source node@10
Run Code Online (Sandbox Code Playgroud)

它无法安装,并且出现以下错误。

./configure: line 3: exec: python: not found
Run Code Online (Sandbox Code Playgroud)

我使用brew安装了python。

brew install python
Run Code Online (Sandbox Code Playgroud)

上面的命令安装了python3,所以我为python创建了别名

alias python=python3
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

所以,python 正在工作。我再次尝试brew install --build-from-source node@10,仍然得到 在此输入图像描述

python macos node.js apple-m1

6
推荐指数
1
解决办法
5565
查看次数

错误:用户未在 NodeJS 中通过 amazon cognito 身份验证

我正在使用amazon-Cognito-identity-jsaws-sdk在我的 NodeJs 应用程序中设置身份验证。

我做了什么

首先,我使用userpool.signUp(..)根据文档的方法进行注册。cognitoUser.confirmRegistration(..)然后我根据文档使用方法确认了验证码。

到目前为止,一切正常。但是,现在我想获取用户的所有属性。cognitoUser.getUserAttributes(..)我找到了一个可以给我属性的方法。但是当我之后调用此方法时,cognitoUser.confirmRegistration(..)它会返回Error: User is notnauthendated

我遇到了一个 SO问题,我得到getCurrentUser()will return null at backend side。

那么,我如何使用nodejs在完全安全的后端授权任何用户呢?

amazon-web-services node.js amazon-cognito

5
推荐指数
1
解决办法
6323
查看次数

peer.on('callll') 永远不会被调用

Peer js 不工作

我只是在 NodeJs 和 ReactJs 中创建peerjs 视频流应用程序


下面的代码工作正常,我能够创建新的对等点,并且open事件也正常工作。

const peer = new Peer(undefined,{
            host:"/",
            port:"5001"
        });

peer.on('open',id=>{
  socket.emit('join-room', roomId,id);
})
Run Code Online (Sandbox Code Playgroud)

在服务器端,每当'join-room'发出事件时,服务器都会发出另一个事件'user-disconnected'并传递userId (peerjs)给客户端。

// server.js
socket.on('join-room',(roomId,userId)=>{
    console.log(`user ${userId} joined ${roomId}`);
    socket.join(roomId);
    socket.to(roomId).emit('user-connected',userId);

    socket.on('disconnect', () => {
        socket.to(roomId).emit('user-disconnected', userId)
    })
})
Run Code Online (Sandbox Code Playgroud)

每当 'user-connected'在客户端触发时,我都会打电话connectToNewUser,到目前为止一切正常。

socket.on('user-connected',userId=>{
    console.log("New user connected...")
    connectToNewUser(userId, stream)
});
Run Code Online (Sandbox Code Playgroud)

错误

这是登录控制台console.log('connectToNewUser',1222.....)没有错误。

但是,这call.on('stream')从来没有被称为

connectToNewUser(userId, stream) {
    console.log('connectToNewUser',userId)
    const call = peer.call(userId, stream);
    const video = …
Run Code Online (Sandbox Code Playgroud)

node.js webrtc reactjs peerjs

5
推荐指数
1
解决办法
4570
查看次数

无法静态分析第 16 行中的“require(…, …)”

我正在使用nextjs。

\n

导入时markdown-toc我遇到了问题。\n/pages/index.js

\n
import toc from "markdown-toc";\n
Run Code Online (Sandbox Code Playgroud)\n

然后我收到以下错误

\n
./node_modules/markdown-toc/lib/utils.js\nCannot statically analyse \'require(\xe2\x80\xa6, \xe2\x80\xa6)\' in line 16\n
Run Code Online (Sandbox Code Playgroud)\n

javascript reactjs next.js

4
推荐指数
1
解决办法
1963
查看次数

在nodejs中使用axios下载图像

const {Buffer} = require("buffer")
const express = require("express");
const axios = require("axios");
const app = express();
let url =
  "https://res.cloudinary.com/practicaldev/image/fetch/s--nh8zSFgY--/c_fill,f_auto,fl_progressive,h_320,q_auto,w_320/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/285604/94170c66-2590-4002-90e0-ec4dc94ed7b5.png";

app.get("/", async(request, response) => {
  const arrayBuffer = await axios.get(url);
  let buffer = Buffer.from(arrayBuffer.data,'binary').toString("base64");
  let image = `data:${arrayBuffer.headers["content-type"]};base64,${buffer}`;
  response.send(`<img src=${image}/>`);
});

app.listen(5001, () => console.log("Server is up and running.."));
Run Code Online (Sandbox Code Playgroud)

图像未显示。后台控制台没有任何错误。缓冲区是有效的 base64 字符串。

输出

在此输入图像描述

base64 buffer node.js axios

4
推荐指数
1
解决办法
6407
查看次数

C++ 中的复合赋值

我想知道C++中复合赋值的执行流程。我遇到了一个CodeChef 问题,其中我正在计算 NCR mod p 值并将它们加在一起以获得最终答案:

// correct
for(int i=min1; i<=max1; i+=2){
     ans = (ans+ncr_mod_p(n,i))%mod;
}
Run Code Online (Sandbox Code Playgroud)
// incorrect
for(int i=min1; i<=max1; i+=2){
     ans+=ncr_mod_p(n,i)%mod;
}
Run Code Online (Sandbox Code Playgroud)

这是由于整数溢出而发生的。

那么,复合赋值的执行顺序是怎样的呢?

比方说,如果我们有一个方程a+=b%c,那么执行顺序是什么:

a = (a+b)%c
// OR
a = a+(b)%c;
Run Code Online (Sandbox Code Playgroud)

c++ assignment-operator compound-assignment

3
推荐指数
2
解决办法
318
查看次数

无法解析名为“存储”的 Azure 存储连接 - Azure 持久函数

我的项目

\n

包.json

\n
{\n  "name": "azure-functions",\n  "version": "1.0.0",\n  "description": "",\n  "scripts": {\n    "start": "func start",\n    "test": "echo \\"No tests yet...\\""\n  },\n  "dependencies": {\n    "durable-functions": "^2.0.2"\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

主机.json

\n
{\n  "version": "2.0",\n  "logging": {\n    "applicationInsights": {\n      "samplingSettings": {\n        "isEnabled": true,\n        "excludedTypes": "Request"\n      }\n    }\n  },\n  "extensionBundle": {\n    "id": "Microsoft.Azure.Functions.ExtensionBundle",\n    "version": "[3.*, 4.0.0)"\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

DurableFunctionsHttpStart/function.json

\n
{\n  "bindings": [\n    {\n      "authLevel": "anonymous",\n      "name": "req",\n      "type": "httpTrigger",\n      "direction": "in",\n      "route": "orchestrators/{functionName}",\n      "methods": [\n        "post",\n        "get"\n      ]\n    },\n    {\n      "name": "$return",\n …
Run Code Online (Sandbox Code Playgroud)

json azure azure-durable-functions

2
推荐指数
1
解决办法
3136
查看次数