我已升级到Visual Studio 16.6.3。当我打开任务运行器浏览器时,它无法加载我的gulp文件,在任务运行器输出窗口中,我可以看到...
Failed to run "E:\Projects\...\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
fs.js:35
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:35:5
at req_ (E:\Projects\...\node_modules\natives\index.js:143:24)
at Object.req [as require] (E:\Projects\...\node_modules\natives\index.js:55:10)
at Object.<anonymous> (E:\Projects\...\node_modules\graceful-fs\fs.js:1:37)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
我随后谷歌了一下,发现这是由于 node 12 和 gulp 3 不兼容导致的问题,建议升级到版本4。因此,我更新了我的 package.json 文件,并将 "gulp": "3.9.1" 更改为 "gulp": "4.0.2"。当我进入任务浏览器时,在任务运行器输出窗口中看到以下内容...
Failed to run "E:\Projects\...\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (E:\Projects\...\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (E:\Projects\...\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (E:\Projects\...\gulpfile.js:86:6)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at requireOrImport (E:\Projects\...\node_modules\gulp\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
我谷歌了一下,建议将gulp降级到3版本...只希望打开任务运行器资源管理器不用花费4个小时来解决依赖问题。
此外,在Visual Studio包管理器控制台内运行“npm install”(无论是提升权限还是非提升权限)似乎只会导致一堆权限错误。我只能在提升的powershell窗口中成功运行npm install。
有人有这些问题的解决方案吗?
Package.json如下...
{
"version": "1.0.0",
"name": "asp.net",
"private": true,
"devDependencies": {
"del": "4.1.1",
"gulp": "3.9.1",
"gulp-concat": "^2.6.1",
"gulp-config": "0.3.0",
"gulp-cssmin": "^0.2.0",
"gulp-csso": "1.1.0",
"gulp-htmlmin": "5.0.1",
"gulp-imagemin": "2.4.0",
"gulp-less": "4.0.1",
"gulp-plumber": "1.2.1",
"gulp-uglify": "3.0.2",
"gulp.spritesmith": "^6.10.0",
"merge-stream": "2.0.0",
"vinyl-buffer": "1.0.1"
}
}
编辑:尝试将Node从12.6.2升级到12.18.2但未成功。
编辑:尝试将Node从12.6.2升级到14.5.0但未成功。
Task function must be specified
是从gulp v3迁移到gulp v4时常见的错误,通常很容易修复。但是您必须展示您的gulp v4 gulpfile.js以获得进一步的帮助。 - Mark