小编Pra*_*pta的帖子

Nodejs,调用performance.getEntriesByType时性能挂钩崩溃

这是我的示例代码

const _performance = require('perf_hooks').performance;

someFunction= ()=>{

    _performance.mark('mark A')

    // Do something
    const a= Array(100000)
    var boo =true;
    a.forEach(el=>{
        boo = ! boo
    })

    _performance.mark('mark B')
    _performance.measure('total','mark B','mark A');

    var measurments = _performance.getEntriesByType('measure');

    measurments.forEach(measurment =>{
        console.log(measurment.name + ' ' + measurment.duration)
    } )

}

someFunction();
Run Code Online (Sandbox Code Playgroud)

它崩溃并显示错误消息

类型错误:_performance.getEntriesByType 不是函数

知道为什么会这样吗?我在 Windows 10 上使用 node v10.7.0

node.js

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

当React客户端尝试获取数据时,如何解决express.js中CORS请求未成功的问题?

我对文件做了很多更改app.js来解决这个问题CORS request did not succeed,但我总是面临同样的问题。如何解决这个问题。我添加了我的 app.js 代码,请检查任何人。谢谢

app.js 代码

var express = require('express');

var bodyParser = require("body-parser");
var app = express();
var cors = require('cors');

const userlogin   = require('./routes/User_route');
const deviceRoutes = require("./routes/Device_route");

app.use('*', cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.set('port', process.env.PORT || 4007);
app.set('host', "*.*.*.*"); 

app.use("/users",userlogin);
app.use("/users", deviceRoutes);
module.exports = app;
Run Code Online (Sandbox Code Playgroud)

错误

类型错误:“尝试获取资源时出现网络错误。” Bundle.js:132447:16

跨源请求被阻止:同源策略不允许读取http://localhost:4007/users/login处的远程资源。(原因:CORS请求未成功)。

node.js cors express

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

nodemon is crashing after several changes done in project files?

When I update the project Files I get this issue given Below:

events.js:183
   throw er; // Unhandled 'error' event
       ^

 Error: listen EADDRINUSE :::4000
at Object._errnoException (util.js:1022:11)
at _exceptionWithHostPort (util.js:1044:20)
at Server.setupListenHandle [as _listen2] (net.js:1351:14)
at listenInCluster (net.js:1392:12)
at Server.listen (net.js:1476:7)
at Function.listen (E:\nodejs-mysql-authentication- master\node_modules\express\lib\application.js:618:24)
at Object.<anonymous> (E:\nodejs-mysql-authentication-master\server.js:26:5)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
[nodemon] app crashed - waiting for file changes before starting...
Run Code Online (Sandbox Code Playgroud)

I already try all this point to short out this issue given below …

node.js npm node-modules nodemon

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

我无法在Java 11中使用@PostConstruct和@PostDestroy

我在项目中使用@PostConstruct和@PostDestroy注释时遇到问题。我不能使用这些注释,尽管我导入了Java的注释,但这些注释似乎并不存在。我正在使用Java 11,这就是我build.gradle文件的内容:

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'org.springframework', name: 'spring-webmvc', version: '5.1.0.RELEASE'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.7'
    compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
    provided group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1' 
}
Run Code Online (Sandbox Code Playgroud)

java annotations spring-mvc

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

NGINX 反向代理后面的 Node.js 应用程序的 POST 和 GET 请求出现 404

我有一个使用以下结构运行的 Ubuntu Web 服务器:

Nginx 反向代理 localhost:80,重定向到当前'/'有效的任意一个(带有 WordPress 站点的 apache 服务器,位于 localhost:8080)。

最近,我尝试在www.site.com/app或内部添加 Node.js 应用程序localhost:3000。我能够为 Node.js Web 应用程序的 HTML 和 CSS 提供服务,但是所有内部路由调用都处于 404ing,可能是因为 /app/ 的 URL 寻址。

IE。尝试命中/someendpoint404,因为 Node.js 从技术上讲是在localhost:3000( www.site.com/app) 上运行的。我应该像 ( www.site.com/app/someendpoint) 这样路由参数吗?

问题:由于我对 NGINX 配置的理解不好,来自 NODE.JS 的所有 POST/GET 调用都是 404ing。如何将此 GET 调用路由到 Node.js 服务器的实际位置(site.com/app/,localhost:3000)。

这是我的“ default”配置/etc/nginx/available_sites/.

 server {
     listen 80 default_server;
     listen [::]:80 default_server;

     root /var/www/html;

     index index.php index.html index.htm index.nginx-debian.html;

     server_name www.*site*.name; …
Run Code Online (Sandbox Code Playgroud)

nginx node.js

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

在ubuntu 14.04上执行dockerode npm的以下代码后出现错误“connect EACCES /var/run/docker.sock”

我正在执行以下代码以在 Ubuntu 14.04 机器上使用 npm dockerode 获取所有容器的列表。Docker 容器运行正常。

var Docker = require('dockerode');
var docker = new Docker({socketPath: '/var/run/docker.sock'});

docker.listContainers({all: true}, function(err, containers) {
console.log('err ' + err);
console.log('ALL: ' + containers);
});
Run Code Online (Sandbox Code Playgroud)

但是得到

错误连接 EACCES /var/run/docker.sock

提前致谢。

ubuntu node.js docker

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

无法从 NUMERIC 单元格中获取 STRING 值?

我正在使用关键字驱动的数据框架通过 Excel 工作表执行测试脚本。

执行时出现错误:

java.lang.RuntimeException: java.lang.IllegalStateException: 无法从 NUMERIC 单元格中获取 STRING 值

我的硒代码是

    package DemoData;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import DataConfig.ExcelDataConfig;

public class ReadArrayData 
{

    WebDriver driver;


  @Test(dataProvider="Tipreports")
  public void Dataprovider(String username, String password) throws InterruptedException
  {
      System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");

      driver = new ChromeDriver();

      driver.get("http://xxxxxxxxxxxxxxxx/");

      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

      driver.manage().window().maximize();

      driver.findElement(By.id("txt_username")).sendKeys(username);

      driver.findElement(By.id("txt_pin")).sendKeys(password);

      driver.findElement(By.xpath("//*[@id='btn_click']")).click();

      Thread.sleep(5000);

      //driver.getCurrentUrl();

      Assert.assertTrue(driver.getCurrentUrl().contains("http://xxxxxxxxxxxxx/Algorithm_Run.aspx"),"User Not able to Login - Invalid Credentials");   

  }

  @AfterMethod
  public void Close()
  {
      driver.quit();
  } …
Run Code Online (Sandbox Code Playgroud)

java testng selenium apache-poi selenium-webdriver

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