error C2039: 'IsNearDeath': is not a membe

2020-08-12 06:32发布

问题:

I recently upgraded my nodejs to v12.3.1, and now when I try to run npm install in my project repository, I am getting the preceding errors.

error C2059: syntax error: ')' (compiling source file ..\src\custo
m_importer_bridge.cpp) 

error C2660: 'v8::StringObject::New': function does not take 1 arg
uments (compiling source file ..\src\sass_context_wrapper.cpp)

node_modules\nan\nan_object_wrap.h(127): error C2039: 'IsNearDeath': is not a member of 'Nan::Persistent<v8::Object,v
8::NonCopyablePersistentTraits<T>>'

Things I have tried

  • Deleted the node_modules folder and run npm install
  • Closed vscode and open the solution again
  • update npm to the latest

Anyone else are facing the same issue with v12.3.1?

回答1:

I have tried many things to solve this issue. It seems like the version v12.3.1 is not stable yet. As a workaround, I installed the version v10.16.0 and that fixed the issue. As I had installed the latest version previously (v12.3.1) the Node.js was not allowing me to install a lower version, so I had to uninstall the Node.js and install the v10.16.0. I hope it helps.

Update:

As @forsunnet mentioned in his comment, the issue is with the version 13.12 too, going back to version 11.x solved the issue for him.



回答2:

I was able to fix the issue (for me at least) on Node v12.13.1:

  • delete package-lock.json
  • delete node_modules directory
  • rerun npm install

Looking at the diff of package-lock.json reveals that some of the problematic packages are obviously outdated: