When I run a project through gulp, one of the above exceptions is thrown. After searching for information, I finally found that after upgrading the node version, it is because gulp v3 runs on the Node.js 12 environment because of one of the dependencies, that is, graceful- fs is not compatible with this caused.
There are two solutions:
1. You can upgrade to gulp v4 (modify the source code, it takes a lot of time), or downgrade the node version.
2. Specifically downgrade the version of graceful -fs in the project.
Because I don't want to upgrade gulp, and I don't want to downgrade node, so I adopt the second solution (forcing our project to install a specific version 4.2.2 of graceful-fs);
- delete node_modules
- Create npm-shrinkwrap.json in the same directory as package.json
- Copy the following in the created npm-shrinkwrap.json
{
"dependencies": {
"graceful-fs": {
"version": "4.2.2"
}
}
}
- Re-run npm install to install dependencies
The key point here is that you cannot use cnpm to install, you must use npm