创建Cordova 4.2.0项目遇模块缺失报错,求适配Node.js版本
Hey there, I’ve run into similar version mismatch headaches before, so let me break this down clearly for you:
The error Cannot find module 'internal/util/types' you’re hitting is 100% due to the incompatible Node.js version (8.10.0) paired with Cordova 4.2.0. Cordova 4.2.0 released back in 2015, and it wasn’t built to support Node.js versions as new as 8.x—those newer Node versions introduced internal module changes that older Cordova versions don’t recognize.
Recommended Node.js Versions for Cordova 4.2.0
- Node.js 0.12.x: This is the most stable and widely recommended pick, as it was the official supported stable Node release when Cordova 4.2.0 launched. Stick to the latest patch version like
0.12.18for the best compatibility. - Node.js 0.10.x: Also fully compatible if you need to match an older legacy environment setup.
- You can also use io.js 1.x to 3.x (io.js was a Node.js fork active at the time), but Node.js 0.12.x is the safer, more standard choice for most cases.
Quick Switch Tip (Optional)
If you work on multiple projects with different Node versions, use a version manager like nvm to switch easily:
- Install
nvmif you haven’t already. - Run
nvm install 0.12.18to grab the compatible version. - Run
nvm use 0.12.18to activate it for your current session. - Try the Cordova
createcommand again—this should fix the module not found error.
Just a heads-up: Node.js 0.12.x is no longer officially supported, so keep it isolated to this specific Cordova 4.2.0 project and don’t use it for modern Node projects.
内容的提问来源于stack exchange,提问作者Mini Bhati

