我将节点版本从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 rebuild和npm install.它在运行后修复 npm rebuild但我不明白它的作用.请解释一下npm rebuild
谢谢
最近我开始使用(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块捕获.我的问题是,这只是语法上的差异吗?请解释或建议我更好地理解这一点.
谢谢