小编Roh*_*her的帖子

'require' 和 'process' 在 ESlint 中没有定义。节点有问题?

我在GitLab. 我更改了.eslint.json使用来自 StackOverflow 的信息的设置。但我仍然有问题。

我的.eslint.json样子:

{
  "extends": "eslint:recommended",
  "rules": {
    "semi": ["warn", "never"],
    "quotes": ["warn", "single"],
    "no-console": ["off"]
  },
  "parserOptions": {
    "ecmaVersion": 9
  },
  "env": {
    "es6": true,
    "node": true,
    "browser": true,
    "amd": true
  },
  "globals": {
    "$": true,
    "require": true
    "process": true
  },
  "root": true
}
Run Code Online (Sandbox Code Playgroud)

env我添加"adm": true和在globals我添加"process": true"require": true

错误是:

错误 'require' 未定义 no-undef

错误“进程”未定义 no-undef

错误所在的文件如下所示:

{
  "extends": "eslint:recommended",
  "rules": { …
Run Code Online (Sandbox Code Playgroud)

node.js eslint

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

记录中嵌套 Spring 配置(ConfigurationProperties)

如何将application.yaml具有嵌套属性的配置映射到 Java 中的类似记录结构?

例如,如果我们有以下 yaml:

foo:
    bar:
        something: 42

    baz:
        otherThing: true

    color: blue
Run Code Online (Sandbox Code Playgroud)

所需的记录结构将类似于:

@ConfigurationProperties(prefix = "foo")
@ConstructorBinding
public record Foo(
    Bar bar,
    Baz baz,
    String color
) {}

// ---

@ConfigurationProperties(prefix = "foo.bar")
@ConstructorBinding
public record Bar(
    int something
) {}

// ---

@ConfigurationProperties(prefix = "foo.baz")
@ConstructorBinding
public record Baz(
    boolean otherThing
) {}
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot java-record java-17

9
推荐指数
2
解决办法
7337
查看次数

没有 SockJS 的 Spring 启动 Websocket

我已经为此挣扎了至少两个星期。我对 websockets 很陌生。我对休息端点有很好的经验。

我的用例很简单。客户端启动一个 websocket 连接,向服务器发送一些信息,服务器使用该信息,并以固定的时间间隔(例如每 5 秒)向客户端发送一些信息。我按照这里的教程 - https://spring.io/guides/gs/messaging-stomp-websocket/ 它按照解释完美运行。根据上面的教程,客户端发起一个 http 请求,该请求被升级为 websocket。

就我而言,前端是一个 angular 10 应用程序,前端开发人员更喜欢使用rxjs/websocket,不想使用SockJS client,因为他确信我们不必支持任何旧版浏览器,这就是我感到震惊的地方. 显然rxjs/websocketws://协议中需要 url 。

从下面的片段中,我认为我的等效 ws 协议是 ws://localhost:8080/test但是,它似乎不起作用。我不确定出了什么问题。任何帮助是极大的赞赏!

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer
{

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config)
    {
        config.enableSimpleBroker("/topic");
        config.setApplicationDestinationPrefixes("/ws/");
    

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry)
    {
        registry.addEndpoint("/test");
    }

}
Run Code Online (Sandbox Code Playgroud)

从教程中,我更改了app.js,如下以测试这一点。

function connect() {
    // var socket = new SockJS('http://localhost:8080/test'); This works perfectly
    // stompClient = Stomp.over(socket);
    ws …
Run Code Online (Sandbox Code Playgroud)

websocket rxjs sockjs spring-boot spring-websocket

7
推荐指数
1
解决办法
589
查看次数

Cypress 在 Ubuntu 上永远无法通过加载屏幕


我使用\n创建了一个新的 React 项目npx create-react-app virtual-office

\n\n

然后我安装了一些东西,比如 styled-components、react-test-library 等

\n\n


然后我用\n安装了 cypressyarn add -D cypress

\n\n

当我尝试使用命令从项目目录运行 cypress
\n./node_modules/.bin/cypress open

\n\n

柏树窗口打开,但旋转器保持打开状态并且不会进一步加载。\n带加载旋转器的 Cypress\n在打开调试器的情况下运行 cypress 看起来可以找到浏览器(有关调试器的输出,请参阅问题末尾)。如果我使用以下命令运行 cypress,我会收到相同的错误
\nyarn run cypress open -b /usr/local/bin/chromium

\n\n

我可以使用命令打开 Chromium 浏览器
\n /usr/local/bin/chromium
\nChromium 的版本是 81.0.4044.92

\n\n

该命令ls -la /usr/local/bin/c*给出结果
\nlrwxrwxrwx 2 root root 13 Apr 16 10:45 /usr/local/bin/chromium -> /usr/bin/snap

\n\n

我也运行了命令

\n\n
node_modules/.bin/cypress cache clear\nnode_modules/.bin/cypress install\nnode_modules/.bin/cypress open\n
Run Code Online (Sandbox Code Playgroud)\n\n

我遇到了同样的问题,赛普拉斯窗口打开,但没有内容加载。
\n我做错了什么?

\n\n

以下是运行命令的日志
\nDEBUG=cypress:* yarn …

linux testing automated-tests node.js cypress

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