gulp build 时出现Cannot find module 'internal/util/types'

 在使用之前一直好用的gulp build编译压缩文件的时候,莫名的跑出这个错误,因为之前一直好用,突然不好用,就怀疑是不是代码出现了问题。但是这个module明显是npm安装的依赖包文件,一般提示cannot find module,都是缺少该依赖包,只要执行npm install xxxxx --save-dev就能解决,但是在这个却是不行。

于是又搜了一下,发现有人说降版本能解决,于是尝试先将node的版本从v10降到V8,问题依然存在,然后又从v8降到v6,再次执行,发现却是是这样。跟node的版本有关系。(如果你想使用node最新版本,那么需要将gulp也升级到响应的版本。需要先将gulp卸载,然后再重新install一下gulp的新版本即可,过程中会出现一系列的cannot find module的错误提示,一次安装这些缺失的模块即可)。

G:\chenqk\app\HAM-Front>gulp build
module.js:549
    throw err;
    ^

Error: Cannot find module 'internal/util/types'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at evalmachine.:31:26
    at Object. (G:\chenqk\app\HAM-Front\node_modules\vinyl-fs\node_modules\graceful-fs\fs.js:11:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

G:\chenqk\app\HAM-Front>npm install internal/util/types --save-dev
npm ERR! code ENOLOCAL
npm ERR! Could not install from "internal\util\types" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\chenqk\AppData\Roaming\npm-cache\_logs\2019-05-23T02_39_55_270Z-debug.log

降级之后,再次执行gulp build

G:\chenqk\app\HAM-Front>gulp build
(node:16816) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[11:01:45] Using gulpfile G:\chenqk\app\HAM-Front\gulpfile.js
[11:01:45] Starting 'build'...
[11:01:45] Starting 'clean'...
[11:01:45] Finished 'build' after 209 ms
[11:01:45] Finished 'clean' after 235 ms
[11:01:45] Starting 'script-build'...
[11:01:52] Finished 'script-build' after 6.8 s
[11:01:52] Starting 'css-build'...
[11:01:52] Finished 'css-build' after 198 ms

这里有Nodejs的不同版本。有需要的可以去下载(现在资源时默认的五分,没有积分又想要的,可以留言,发过去)

https://download.csdn.net/download/chenqk_123/11195134

你可能感兴趣的:(前端,node,gulp,build,module,not,found)