Grunt Serve 因 cdnify 加载错误而停​​止工作

Raj*_*han 1 gruntjs bower angular

当我运行grunt serve命令时,我遇到了新安装的 Angular 错误

我正在将 Node 12.6.1 与 Source Tree 一起使用并验证是否安装了 bower

Loading "cdnify.js" tasks...ERROR
>> ReferenceError: primordials is not defined

Running "serve" task

Running "clean:server" (clean) task
>> 1 path cleaned.

Running "wiredep:app" (wiredep) task

Running "wiredep:test" (wiredep) task

Running "concurrent:server" (concurrent) task

    Loading "cdnify.js" tasks...ERROR
    >> ReferenceError: primordials is not defined

    Running "copy:styles" (copy) task
    Copied 3 files

    Done.


    Execution Time (2020-02-21 18:22:53 UTC+5:30)
    loading tasks  13ms  ??????????? 22%
    copy:styles    45ms  ????????????????????????????????????? 78%
    Total 58ms

Running "autoprefixer:server" (autoprefixer) task
>> 3 autoprefixed stylesheets created.

Running "connect:livereload" (connect) task
Started connect web server on http://localhost:9000

Run Code Online (Sandbox Code Playgroud)

Rob*_*rto 9

cdnify 插件已经过时,不再维护。您可以使用其中一种替代品。我使用grunt-google-cdn2

第一步:添加包

npm install --save grunt-google-cdn2

第2步:改变咕噜-cdnify插件加载使用新的包在你的Gruntfile.js

您的 Gruntfile.js 可能会有所不同,但您需要将您使用的插件从grunt-cdnify 更改grunt-google-cdn2

// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn2',
    chokidar: 'grunt-chokidar',
    serveStatic: 'serve-static',        
});
Run Code Online (Sandbox Code Playgroud)

第 3 步:package.json 中删除旧的 grunt-cdnify 插件