ionic-team / ionic-v3

The repo for Ionic 3.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
129 stars 86 forks source link

ionic cordova build --prod TypeError on ionic-app-script task: "build" postprocess #1148

Closed rfitoc closed 2 years ago

rfitoc commented 2 years ago

I'm submitting a ... (check one with "x") [ x] bug report [ ] feature request

Current behavior:

.... [13:11:38] ionic-app-script task: "build" [13:11:38] TypeError: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined at Object.writeFileSync (fs.js:1521:5) at C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\@ionic\app-scripts\dist\postprocess.js:48:20 at Array.forEach () at writeFilesToDisk (C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\@ionic\app-scripts\dist\postprocess.js:36:11) at postprocessWorker (C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\@ionic\app-scripts\dist\postprocess.js:26:23) at Object.postprocess (C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\@ionic\app-scripts\dist\postprocess.js:13:12) at C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\@ionic\app-scripts\dist\build.js:131:30 at processTicksAndRejections (internal/process/task_queues.js:95:5)

Expected behavior:

I hope that the build finish successfully.

Steps to reproduce:

ionic cordova build android --prod

or

npm run build --prod --> ionic-app-scripts build

Related code:

I have analized postprocess.js script and add the next code to print the possible problem:

 if(!file.content){
          console.log(file)
          console.log(file.path)
          console.log(fileToWrite);
        }

The result is:

path: 'C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\ionic-angular\config\mode-registry.js.map', content: undefined, timestamp: 1638360677667 C:\Users\Ruben\Projectes\zinkolas-app-order-processing\node_modules\ionic-angular\config\mode-registry.js.map C:\Users\Ruben\Projectes\zinkolas-app-order-processing.tmp\node_modules\ionic-angular\config\mode-registry.js.map

This file exists and i can load it with other script. I don't know if it happens with other files.

Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

[WARN] Detected locally installed Ionic CLI, but it's too old--using global CLI.

Ionic:

   Ionic CLI          : 6.4.0 (C:\Users\Ruben\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 10.0.0 (cordova-lib@10.1.0)
   Cordova Platforms : android 9.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 1.2.1, (and 8 other plugins)

Utility:

   cordova-res : 0.15.3
   native-run  : 0.3.0

System:

   Android SDK Tools : 26.1.1 (C:\Users\Ruben\AppData\Local\Android\Sdk)
   NodeJS            : v14.18.1 (C:\PROGRA~1\nodejs\node.exe)
   npm               : 6.14.15
   OS                : Windows 10

I don't know if it's important but i have own Webpack:

var path = require('path');
var useDefaultConfig = require('@ionic/app-scripts/config/webpack.config.js');

module.exports = function () {
    console.log("Environment: " + process.env.IONIC_ENV);
    useDefaultConfig[process.env.IONIC_ENV].resolve.alias = {
        "@environment": path.resolve(__dirname + '/../../src/env/env.' + process.env.IONIC_ENV + '.ts'),
    };
    return useDefaultConfig;
};
rfitoc commented 2 years ago

I found the problem.

I downgrade nodejs to 12.22.7 version and it works.

I know that it exists a version dependency between ionic, angular, typescript, npm plugins and node, but it would be great that the frameworks and scripts inform of these dependencies on execution time.

Thank you.

Best Regards.