小编Pas*_*ers的帖子

覆盖对等依赖项时出错 - npm install Reactstrap

"@popperjs/core": "^2.6.0",
"@testing-/jest-dom": "^5.11.9",
"@testing-/react": "^11.2.3",
"@testing-/user-event": "^12.6.2",
"bootstrap": "^4.6.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"react-transition-group": "^4.4.1",
Run Code Online (Sandbox Code Playgroud)

我在 package.json 文件中拥有的依赖项的版本。

G:\Projects\React\confusion> npm install --save Reactstrap

npm WARN ERESOLVE 覆盖对等依赖
npm WARN 发现:react@17.0.1
npm WARN node_modules/react
npm WARN Peer React@" " from @testing-/react@11.2.3
npm WARN node_modules/@testing-/react
npm WARN @testing -/react@"^11.2.3" 来自根项目
npm WARN 3 more (react-dom、根项目、reactstrap)
npm WARN
npm WARN 无法解析依赖关系:
npm WARN Peer React@"0.14.x || ^ 15.0.0 || ^16.0.0" 来自react-popper@1.3.7
npm 警告node_modules/react-popper
npm 警告react-popper@"^1.3.6" 来自reactstrap@8.9.0
npm 警告node_modules/reactstrap
npm ERR …

javascript npm reactjs reactstrap

10
推荐指数
3
解决办法
9万
查看次数

Slack API - chat.update:"message_not_found"

我正在使用'slack-node'npm包为我的团队构建一个简单的Slack App.到目前为止,机器人的初始化工作很好.我使用自定义斜杠命令后将消息发送到通道.此消息包含一个交互式按钮,在用户按下该消息后,该消息应该更新.

从我的日志:

// User uses /event slash command
18:48:50 UTC - - Received [POST] to path [/event]

// API response after posting the message
{ ok: true, message_ts: '1506538130.000343' }

// Incoming request after user pressed the button
18:49:32 UTC - - Received [POST] to path [/button_reply]

// Extracted channel id and message ts
C3PEQESP5 1506538130.000343

// respond after using chat.update
{ ok: false, error: 'message_not_found' }
Run Code Online (Sandbox Code Playgroud)

我确保传递正确的通道ID和消息ts,我100%确定这些参数是正确的,因为您只需要比较响应(对象).

这是我正在使用的软件包:https://www.npmjs.com/package/slack-node

这是我正在使用的代码片段:

module.exports = {

 postEphemeral : function(text, …
Run Code Online (Sandbox Code Playgroud)

node.js slack-api

5
推荐指数
2
解决办法
2412
查看次数

nuxt 项目 onvercel 中的 process.env.URL null

我正在 vercel 上部署 nuxt 应用程序。我按照本指南为 vercel 环境添加了一个秘密 - https://vercel.com/docs/environment-variables#secret-environment-variables

在本地,我使用 dotenv 并且它运行良好,将 .env 文件中的变量加载到process.env.Tokenprocess.env.Token在 vercel 上部署时为空。

如何解决这个问题?

javascript environment-variables node.js vercel

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

如何在没有控制器的 Nestjs 应用程序中使用 rxjs/Observables

Nestjs建议使用HttpModule, 导入来@nestjs/axios执行对外部 API 的请求。我知道将HttpService响应转换为Observables.

目标

从外部 API 请求数据并在应用程序内部使用数据。

问题

我无法理解如何实际从请求中检索数据。我在其他一些答案中读到,如果您从 a 返回可观察值Controller,Nestjs 将自动为您处理它并将数据返回给客户端。这很好,但是,我没有在Controller. 我需要数据在应用程序内可用。

我有一个服务:

@Injectable()
export class ExampleService {

  // constructor

  getData(): Observable<AxiosResponse<any[]>> {
    return this.httpService.get(`http://some-url.com`);
  }

}
Run Code Online (Sandbox Code Playgroud)

如何getData()在应用程序逻辑中使用来获取返回的数据ObservablePromises在这种情况下,使用普通的 axios 请求而不使用会更好吗HttpModule

到目前为止我发现的唯一解决方案是使用subscribe

this.httpService.get(`http://some-url.com`)
.subscribe((value) => {
  console.log(value);
});
Run Code Online (Sandbox Code Playgroud)

与所有花哨的async ... awaits.

rxjs axios nestjs

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

猫鼬 Mongo错误:11000

我通过邮差发送了一个创建帖子信号。有一次,邮政信号成功。但下次又失败了。错误信息是这样的。

Error creating new record : {
  "driver": true,
  "name": "MongoError",
  "index": 0,
  "code": 11000,
  "keyPattern": {
    "RoutineParts.userId": 1
  },
  "keyValue": {
    "RoutineParts.userId": null
  }
}
Run Code Online (Sandbox Code Playgroud)

我无法理解错误消息,我的邮政编码和用户模型代码是这样的,

// it's post code. 

router.post('/',(req,res)=>{
    const newRecord = User ({
        username : req.body.username,
        email : req.body.email,
        password : req.body.password
    })

    newRecord.save((err,docs)=>{
        if(!err) {
            res.send(docs)
        }else {
            console.log('Error creating new record : ' + JSON.stringify(err,undefined,2))
        }
    })
})

// it's user model
const mongoose = require('mongoose')

const userSchema = new mongoose.Schema(
    {
        username : …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

3
推荐指数
1
解决办法
3643
查看次数

在电子应用程序中在运行时加载 Nodejs 模块

目前,我玩弄electron利用vue-cli-plugin-electron-builder沿边简单VUE项目。这是项目https://github.com/nklayman/vue-cli-plugin-electron-builder

   vue create my-project
   cd my-project
   vue add electron-builder
   npm run electron:serve
Run Code Online (Sandbox Code Playgroud)

我的目标是添加一个简单的类似插件的架构。该应用程序仅提供基本功能,但可以使用“插件”进行扩展。因此,这些插件不包含在构建中,但会在运行时由电子加载。我更喜欢这些插件的行为就像节点模块 ( module.exports =) 和它自己的依赖项(可能里面有一个 package.json 文件)。我会在app.getPath('userData') + '/Plugins.

我查看了一些关于如何解决这个问题的方法:


1.使用Nodejsvm模块

首先,我尝试使用 Nodejsvm模块在运行时从外部文件读取和执行脚本。到目前为止,它工作得很好,尽管我无法在那些加载的脚本中使用外部依赖项。如果我想在插件脚本中使用外部依赖项,这些依赖项必须事先包含在电子构建中。不知何故破坏了拥有插件的整个目的......只有普通的 js + nodejs 基本模块是可能的。


2.使用 global.require

我在另一个 SO 答案中看到了这个解决方案。

他们说要使用,global.require但它会抛出一个错误说global.require is not a function。该解决方案首先看起来很有希望,但不知何故我无法让它发挥作用。


3.简单使用 require

我当然得试一试。当我尝试require从非项目位置访问外部模块时,即使路径正确,它也找不到该模块。同样,我试图定位模块的路径应该在app.getPath("userData"),而不是在项目根目录中。但是,当我在项目的根目录中找到插件时,它包含在 build.gradle 文件中。这再次违背了拥有插件的目的。


目标

到目前为止,我还没有找到可行的解决方案。我只是希望我的电子应用程序可以在运行时使用基本节点模块进行扩展(遵循预定义的模式来简化)。当然有atom,用电子制造,使用他们自己的apm管理器来安装和加载插件,但这似乎是一种压倒性的方式。对我来说只有本地的插件文件就足够了,拥有一个公共“市场”不是目标。此外,如果应用程序必须重新加载/重新启动以加载插件,那也没关系。 …

node.js vue.js electron

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