nativescript - 失败 "tns run android –bundle"选项对象无效

标签 nativescript angular2-nativescript

当我使用 ngserve 运行时,我的应用程序运行良好,但是当我使用 tns run android --bundletns run android 时,它给了我以下异常。

Searching for devices...
Preparing project...
Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
 - options[0] misses the property 'patterns'. Should be:
   [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
 - options[1] misses the property 'patterns'. Should be:
   [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
 - options[2] misses the property 'patterns'. Should be:
   [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
    at validate (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\schema-utils\dist\validate.js:96:11)
    at new CopyPlugin (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\copy-webpack-plugin\dist\index.js:24:30)
    at module.exports (C:\Ambiente PGE\workspace\ui\app-mobile\webpack.config.js:304:13)
    at handleFunction (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\prepareOptions.js:23:13)
    at prepareOptions (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\prepareOptions.js:9:5)
    at requireConfig (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\convert-argv.js:136:14)
    at C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\convert-argv.js:142:17
    at Array.forEach (<anonymous>)
    at module.exports (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\convert-argv.js:140:15)
    at C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\cli.js:241:39
    at Object.parse (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\node_modules\yargs\yargs.js:567:18)
    at C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\cli.js:219:8
    at Object.<anonymous> (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack-cli\bin\cli.js:538:3)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (C:\Ambiente PGE\workspace\ui\app-mobile\node_modules\webpack\bin\webpack.js:156:2)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
Executing webpack failed with exit code 1.

我创建的项目如下:

ng new my-mobile
ng add @nativescript/schematics

我已经将 cli、npm 和 nativescript 更新到最新版本

最佳答案

同样的事情也发生在我身上,当我尝试编辑 webpack.config.js 时,它对我有用,只需替换行

    new CopyWebpackPlugin([
            { from: { glob: "fonts/**" } },
            { from: { glob: "**/*.jpg" } },
            { from: { glob: "**/*.png" } },
        ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),

成为

  new CopyWebpackPlugin({
                patterns: [
                  { from: "fonts/**", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
                  { from: "**/*.{jpg,png}", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
                ]
              }, { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),

如果您没有字体文件夹,请不要忘记添加字体文件夹

关于nativescript - 失败 "tns run android –bundle"选项对象无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62453643/

相关文章:

firebase - 我无法获取要使用 nativescript 上传的文件的大小

angular - Nativescript Angular 找不到模块 "nativescript-angular/forms"

android - 显示黑色 map 标记的 nativescript-mapbox

angularjs - 将选项卡 View 重新定位到 nativescript Angular 的底部

javascript - 在 Nativescript Angular 应用程序中,application.start()/run() 在哪里?

android - Nativescript在android和ios中访问localhost访问

javascript - Nativescript Canvas

css - 有没有办法提高 NativeScript 中 scss 文件加载的性能?

javascript - 未捕获( promise ): Server error

angular - 将 NativeScript 插件与 NativeScript Angular 2 结合使用