小编Pus*_*mar的帖子

'npm install'和'npm rebuild'之间有什么区别?

我将节点版本从v7.1.0升级到v9.4.0.在此之后,我试图运行我的服务器,然后我得到了这个.

was compiled against a different Node.js version using
NODE_MODULE_VERSION 51. This version of Node.js requires
NODE_MODULE_VERSION 59. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
Run Code Online (Sandbox Code Playgroud)

然后我知道npm rebuild.我运行命令npm rebuildnpm install.它在运行后修复 npm rebuild但我不明白它的作用.请解释一下npm rebuild

谢谢

node.js npm

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

使用async/await与使用Promise有何不同?

最近我开始使用(Async&Await).在此之前,我使用Promise使我的进程异步.喜欢:

example.firstAsyncRequest()
.then(firstResponse => {
    return example.secondAsyncRequest(firstResponse)
})
.then(secondResponse => {
    return example.thirdAsyncRequest(secondResponse)
})
.then(result => {
    console.log(result)
})
.catch(err => {
    console.log(err)
})
Run Code Online (Sandbox Code Playgroud)

现在我实现这个目标:

  try {
    const firstResponse = await example.firstAsyncRequest();
    const secondResponse = await example.secondAsyncRequest(firstResponse);
    const thirdAsyncRequest = await example.thirdAsyncRequest(secondResponse);
    console.log(thirdAsyncRequest)
  }
  catch (error) {
    // Handle error
  }
Run Code Online (Sandbox Code Playgroud)

在两者中,代码块方法一个接一个地执行,最后抛出一个错误(如果有的话)并被catch块捕获.我的问题是,这只是语法上的差异吗?请解释或建议我更好地理解这一点.

谢谢

javascript node.js

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

Java中出现意外结果(浮动到整数)

我有这个问题

System.out.print((9/5) * 3);
Run Code Online (Sandbox Code Playgroud)

我期待结果,5.4但它返回3.为什么会这样?

java

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

标签 统计

node.js ×2

java ×1

javascript ×1

npm ×1