webpack / webpack-cli

Webpack's Command Line Interface
https://webpack.js.org/api/cli
MIT License
2.56k stars 598 forks source link

Main entry is missing. App cannot be started. Verify app bootstrap. #1077

Closed zeeshan-mehdi closed 5 years ago

zeeshan-mehdi commented 5 years ago

what caused problem ?

My project was on cli version 5.3 i updated it to the latest cli version 6 and also updated all the packages including npm.

Problem

It says An uncaught Exception occurred on "main" thread. System.err: Unable to start activity ComponentInfo{org.te.FirmApp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap. System.err: System.err: StackTrace: System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.te.FirmApp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate fai led System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.

image

package.json

{ "nativescript": { "id": "org.te.FirmApp", "tns-ios": { "version": "6.0.1" }, "tns-android": { "version": "6.0.0" } }, "description": "NativeScript Application", "license": "SEE LICENSE IN <your-license-filename>", "repository": "<fill-your-repository-here>", "scripts": { "lint": "tslint \"src/**/*.ts\"" }, "dependencies": { "@angular/animations": "8.0.0", "@angular/common": "8.0.0", "@angular/compiler": "8.0.0", "@angular/core": "8.0.0", "@angular/forms": "8.0.0", "@angular/http": "8.0.0-beta.10", "@angular/platform-browser": "8.0.0", "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "8.0.2", "nativescript-checkbox": "^3.0.3", "nativescript-geolocation": "^5.1.0", "nativescript-imagepicker": "^6.2.0", "nativescript-loading-indicator": "^2.5.1", "nativescript-paypal-checkout": "^2.1.1", "nativescript-plugin-firebase": "^9.0.1", "nativescript-sqlite": "^2.3.3", "nativescript-theme-core": "~1.0.4", "nativescript-toast": "^2.0.0", "nativescript-ui-autocomplete": "5.0.0", "nativescript-ui-listview": "7.0.0", "nativescript-ui-sidedrawer": "7.0.0", "reflect-metadata": "~0.1.12", "rxjs": "~6.3.0", "tns-core-modules": "6.0.1", "zone.js": "0.9.1" }, "devDependencies": { "@angular/compiler-cli": "8.0.0", "@nativescript/schematics": "~0.5.0", "@ngtools/webpack": "8.0.0", "codelyzer": "~4.5.0", "nativescript-dev-webpack": "1.0.1", "tslint": "~5.11.0", "node-sass": "4.12.0", "typescript": "3.4.5" }, "gitHead": "803cec054c44c99eaa59cdc267993e6346f6cb3a", "readme": "NativeScript Application" }

main.ts

image

ts config

image

nsconfig

image

webpack-config.json

`const { join, relative, resolve, sep, dirname } = require("path");

const webpack = require("webpack"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); const { nsReplaceBootstrap } = require("nativescript-dev-webpack/transformers/ns-replace-bootstrap"); const { nsReplaceLazyLoader } = require("nativescript-dev-webpack/transformers/ns-replace-lazy-loader"); const { nsSupportHmrNg } = require("nativescript-dev-webpack/transformers/ns-support-hmr-ng"); const { getMainModulePath } = require("nativescript-dev-webpack/utils/ast-utils"); const CleanWebpackPlugin = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const TerserPlugin = require("terser-webpack-plugin"); const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin"); const hashSalt = Date.now().toString();

module.exports = env => { // Add your custom Activities, Services and other Android app components here. const appComponents = [ "tns-core-modules/ui/frame", "tns-core-modules/ui/frame/activity", ];

const platform = env && (env.android && "android" || env.ios && "ios");
if (!platform) {
    throw new Error("You need to provide a target platform!");
}

const AngularCompilerPlugin = getAngularCompilerPlugin(platform);
const projectRoot = __dirname;

// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));

const {
    // The 'appPath' and 'appResourcesPath' values are fetched from
    // the nsconfig.json configuration file
    // when bundling with `tns run android|ios --bundle`.
    appPath = "src",
    appResourcesPath = "App_Resources",

    // You can provide the following flags when running 'tns run android|ios'
    aot, // --env.aot
    snapshot, // --env.snapshot,
    production, // --env.production
    uglify, // --env.uglify
    report, // --env.report
    sourceMap, // --env.sourceMap
    hiddenSourceMap, // --env.hiddenSourceMap
    hmr, // --env.hmr,
    unitTesting, // --env.unitTesting
    verbose, // --env.verbose
} = env;

const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap;
const externals = nsWebpack.getConvertedExternals(env.externals);
const appFullPath = resolve(projectRoot, appPath);
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
const tsConfigName = "tsconfig.tns.json";
const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`;
const entryPath = `.${sep}${entryModule}`;
const entries = { bundle: entryPath };
const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1);
if (platform === "ios" && !areCoreModulesExternal) {
    entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules";
};

const ngCompilerTransformers = [];
const additionalLazyModuleResources = [];
if (aot) {
    ngCompilerTransformers.push(nsReplaceBootstrap);
}

if (hmr) {
    ngCompilerTransformers.push(nsSupportHmrNg);
}

// when "@angular/core" is external, it's not included in the bundles. In this way, it will be used
// directly from node_modules and the Angular modules loader won't be able to resolve the lazy routes
// fixes https://github.com/NativeScript/nativescript-cli/issues/4024
if (env.externals && env.externals.indexOf("@angular/core") > -1) {
    const appModuleRelativePath = getMainModulePath(resolve(appFullPath, entryModule), tsConfigName);
    if (appModuleRelativePath) {
        const appModuleFolderPath = dirname(resolve(appFullPath, appModuleRelativePath));
        // include the lazy loader inside app module
        ngCompilerTransformers.push(nsReplaceLazyLoader);
        // include the new lazy loader path in the allowed ones
        additionalLazyModuleResources.push(appModuleFolderPath);
    }
}

const ngCompilerPlugin = new AngularCompilerPlugin({
    hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]),
    platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule), projectRoot)),
    mainPath: join(appFullPath, entryModule),
    tsConfigPath: join(__dirname, tsConfigName),
    skipCodeGeneration: !aot,
    sourceMap: !!isAnySourceMapEnabled,
    additionalLazyModuleResources: additionalLazyModuleResources
});

let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);

const itemsToClean = [`${dist}/**/*`];
if (platform === "android") {
    itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`);
    itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`);
}

nsWebpack.processAppComponents(appComponents, platform);
const config = {
    mode: production ? "production" : "development",
    context: appFullPath,
    externals,
    watchOptions: {
        ignored: [
            appResourcesFullPath,
            // Don't watch hidden files
            "**/.*",
        ]
    },
    target: nativescriptTarget,
    entry: entries,
    output: {
        pathinfo: false,
        path: dist,
        sourceMapFilename,
        libraryTarget: "commonjs2",
        filename: "[name].js",
        globalObject: "global",
        hashSalt
    },
    resolve: {
        extensions: [".ts", ".js", ".scss", ".css"],
        // Resolve {N} system modules from tns-core-modules
        modules: [
            resolve(__dirname, "node_modules/tns-core-modules"),
            resolve(__dirname, "node_modules"),
            "node_modules/tns-core-modules",
            "node_modules",
        ],
        alias: {
            '~': appFullPath
        },
        symlinks: true
    },
    resolveLoader: {
        symlinks: false
    },
    node: {
        // Disable node shims that conflict with NativeScript
        "http": false,
        "timers": false,
        "setImmediate": false,
        "fs": "empty",
        "__dirname": false,
    },
    devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
    optimization: {
        runtimeChunk: "single",
        splitChunks: {
            cacheGroups: {
                vendor: {
                    name: "vendor",
                    chunks: "all",
                    test: (module, chunks) => {
                        const moduleName = module.nameForCondition ? module.nameForCondition() : '';
                        return /[\\/]node_modules[\\/]/.test(moduleName) ||
                            appComponents.some(comp => comp === moduleName);
                    },
                    enforce: true,
                },
            }
        },
        minimize: !!uglify,
        minimizer: [
            new TerserPlugin({
                parallel: true,
                cache: true,
                sourceMap: isAnySourceMapEnabled,
                terserOptions: {
                    output: {
                        comments: false,
                        semicolons: !isAnySourceMapEnabled
                    },
                    compress: {
                        // The Android SBG has problems parsing the output
                        // when these options are enabled
                        'collapse_vars': platform !== "android",
                        sequences: platform !== "android",
                    }
                }
            })
        ],
    },
    module: {
        rules: [
            {
                test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
                use: [
                    // Require all Android app components
                    platform === "android" && {
                        loader: "nativescript-dev-webpack/android-app-components-loader",
                        options: { modules: appComponents }
                    },

                    {
                        loader: "nativescript-dev-webpack/bundle-config-loader",
                        options: {
                            angular: true,
                            loadCss: !snapshot, // load the application css if in debug mode
                            unitTesting,
                            appFullPath,
                            projectRoot,
                            ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
                        }
                    },
                ].filter(loader => !!loader)
            },

            { test: /\.html$|\.xml$/, use: "raw-loader" },

            // tns-core-modules reads the app.css and its imports using css-loader
            {
                test: /[\/|\\]app\.css$/,
                use: [
                    "nativescript-dev-webpack/style-hot-loader",
                    { loader: "css-loader", options: { url: false } }
                ]
            },
            {
                test: /[\/|\\]app\.scss$/,
                use: [
                    "nativescript-dev-webpack/style-hot-loader",
                    { loader: "css-loader", options: { url: false } },
                    "sass-loader"
                ]
            },

            // Angular components reference css files and their imports using raw-loader
            { test: /\.css$/, exclude: /[\/|\\]app\.css$/, use: "raw-loader" },
            { test: /\.scss$/, exclude: /[\/|\\]app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },

            {
                test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
                use: [
                    "nativescript-dev-webpack/moduleid-compat-loader",
                    "nativescript-dev-webpack/lazy-ngmodule-hot-loader",
                    "@ngtools/webpack",
                ]
            },

            // Mark files inside `@angular/core` as using SystemJS style dynamic imports.
            // Removing this will cause deprecation warnings to appear.
            {
                test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
                parser: { system: true },
            },
        ],
    },
    plugins: [
        // Define useful constants like TNS_WEBPACK
        new webpack.DefinePlugin({
            "global.TNS_WEBPACK": "true",
            "process": "global.process",
        }),
        // Remove all files from the out dir.
        new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }),
        // Copy assets to out dir. Add your own globs as needed.
        new CopyWebpackPlugin([
            { from: { glob: "fonts/**" } },
            { from: { glob: "**/*.jpg" } },
            { from: { glob: "**/*.png" } },
        ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
        new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
        // For instructions on how to set up workers with webpack
        // check out https://github.com/nativescript/worker-loader
        new NativeScriptWorkerPlugin(),
        ngCompilerPlugin,
        // Does IPC communication with the {N} CLI to notify events when running in watch mode.
        new nsWebpack.WatchStateLoggerPlugin(),
    ],
};

if (report) {
    // Generate report files for bundles content
    config.plugins.push(new BundleAnalyzerPlugin({
        analyzerMode: "static",
        openAnalyzer: false,
        generateStatsFile: true,
        reportFilename: resolve(projectRoot, "report", `report.html`),
        statsFilename: resolve(projectRoot, "report", `stats.json`),
    }));
}

if (snapshot) {
    config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({
        chunk: "vendor",
        angular: true,
        requireModules: [
            "reflect-metadata",
            "@angular/platform-browser",
            "@angular/core",
            "@angular/common",
            "@angular/router",
            "nativescript-angular/platform-static",
            "nativescript-angular/router",
        ],
        projectRoot,
        webpackConfig: config,
    }));
}

if (hmr) {
    config.plugins.push(new webpack.HotModuleReplacementPlugin());
}

return config;

}; `

To Reproduce clone this project https://github.com/zeeshan-mehdi/driver-app

zeeshan-mehdi commented 5 years ago

what caused problem ?

My project was on cli version 5.3 i updated it to the latest cli version 6 and also updated all the packages including npm.

Problem

It says An uncaught Exception occurred on "main" thread. System.err: Unable to start activity ComponentInfo{org.te.FirmApp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap. System.err: System.err: StackTrace: System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.te.FirmApp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate fai led System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.

image

package.json

{ "nativescript": { "id": "org.te.FirmApp", "tns-ios": { "version": "6.0.1" }, "tns-android": { "version": "6.0.0" } }, "description": "NativeScript Application", "license": "SEE LICENSE IN ", "repository": "", "scripts": { "lint": "tslint \"src/*/.ts\"" }, "dependencies": { "@angular/animations": "8.0.0", "@angular/common": "8.0.0", "@angular/compiler": "8.0.0", "@angular/core": "8.0.0", "@angular/forms": "8.0.0", "@angular/http": "8.0.0-beta.10", "@angular/platform-browser": "8.0.0", "@angular/platform-browser-dynamic": "8.0.0", "@angular/router": "8.0.0", "nativescript-angular": "8.0.2", "nativescript-checkbox": "^3.0.3", "nativescript-geolocation": "^5.1.0", "nativescript-imagepicker": "^6.2.0", "nativescript-loading-indicator": "^2.5.1", "nativescript-paypal-checkout": "^2.1.1", "nativescript-plugin-firebase": "^9.0.1", "nativescript-sqlite": "^2.3.3", "nativescript-theme-core": "~1.0.4", "nativescript-toast": "^2.0.0", "nativescript-ui-autocomplete": "5.0.0", "nativescript-ui-listview": "7.0.0", "nativescript-ui-sidedrawer": "7.0.0", "reflect-metadata": "~0.1.12", "rxjs": "~6.3.0", "tns-core-modules": "6.0.1", "zone.js": "0.9.1" }, "devDependencies": { "@angular/compiler-cli": "8.0.0", "@nativescript/schematics": "~0.5.0", "@ngtools/webpack": "8.0.0", "codelyzer": "~4.5.0", "nativescript-dev-webpack": "1.0.1", "tslint": "~5.11.0", "node-sass": "4.12.0", "typescript": "3.4.5" }, "gitHead": "803cec054c44c99eaa59cdc267993e6346f6cb3a", "readme": "NativeScript Application" }

main.ts

image

ts config

image

nsconfig

image

webpack-config.json

`const { join, relative, resolve, sep, dirname } = require("path");

const webpack = require("webpack"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); const { nsReplaceBootstrap } = require("nativescript-dev-webpack/transformers/ns-replace-bootstrap"); const { nsReplaceLazyLoader } = require("nativescript-dev-webpack/transformers/ns-replace-lazy-loader"); const { nsSupportHmrNg } = require("nativescript-dev-webpack/transformers/ns-support-hmr-ng"); const { getMainModulePath } = require("nativescript-dev-webpack/utils/ast-utils"); const CleanWebpackPlugin = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); const TerserPlugin = require("terser-webpack-plugin"); const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin"); const hashSalt = Date.now().toString();

module.exports = env => { // Add your custom Activities, Services and other Android app components here. const appComponents = [ "tns-core-modules/ui/frame", "tns-core-modules/ui/frame/activity", ];

const platform = env && (env.android && "android" || env.ios && "ios"); if (!platform) { throw new Error("You need to provide a target platform!"); }

const AngularCompilerPlugin = getAngularCompilerPlugin(platform); const projectRoot = __dirname;

// Default destination inside platforms//... const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));

const { // The 'appPath' and 'appResourcesPath' values are fetched from // the nsconfig.json configuration file // when bundling with tns run android|ios --bundle. appPath = "src", appResourcesPath = "App_Resources",

// You can provide the following flags when running 'tns run android|ios'
aot, // --env.aot
snapshot, // --env.snapshot,
production, // --env.production
uglify, // --env.uglify
report, // --env.report
sourceMap, // --env.sourceMap
hiddenSourceMap, // --env.hiddenSourceMap
hmr, // --env.hmr,
unitTesting, // --env.unitTesting
verbose, // --env.verbose

} = env;

const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap; const externals = nsWebpack.getConvertedExternals(env.externals); const appFullPath = resolve(projectRoot, appPath); const appResourcesFullPath = resolve(projectRoot, appResourcesPath); const tsConfigName = "tsconfig.tns.json"; const entryModule = ${nsWebpack.getEntryModule(appFullPath, platform)}.ts; const entryPath = .${sep}${entryModule}; const entries = { bundle: entryPath }; const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1); if (platform === "ios" && !areCoreModulesExternal) { entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules"; };

const ngCompilerTransformers = []; const additionalLazyModuleResources = []; if (aot) { ngCompilerTransformers.push(nsReplaceBootstrap); }

if (hmr) { ngCompilerTransformers.push(nsSupportHmrNg); }

// when "@angular/core" is external, it's not included in the bundles. In this way, it will be used // directly from node_modules and the Angular modules loader won't be able to resolve the lazy routes // fixes https://github.com/NativeScript/nativescript-cli/issues/4024 if (env.externals && env.externals.indexOf("@angular/core") > -1) { const appModuleRelativePath = getMainModulePath(resolve(appFullPath, entryModule), tsConfigName); if (appModuleRelativePath) { const appModuleFolderPath = dirname(resolve(appFullPath, appModuleRelativePath)); // include the lazy loader inside app module ngCompilerTransformers.push(nsReplaceLazyLoader); // include the new lazy loader path in the allowed ones additionalLazyModuleResources.push(appModuleFolderPath); } }

const ngCompilerPlugin = new AngularCompilerPlugin({ hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]), platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule), projectRoot)), mainPath: join(appFullPath, entryModule), tsConfigPath: join(__dirname, tsConfigName), skipCodeGeneration: !aot, sourceMap: !!isAnySourceMapEnabled, additionalLazyModuleResources: additionalLazyModuleResources });

let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);

const itemsToClean = [${dist}/**/*]; if (platform === "android") { itemsToClean.push(${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}); itemsToClean.push(${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}); }

nsWebpack.processAppComponents(appComponents, platform); const config = { mode: production ? "production" : "development", context: appFullPath, externals, watchOptions: { ignored: [ appResourcesFullPath, // Don't watch hidden files "*/.", ] }, target: nativescriptTarget, entry: entries, output: { pathinfo: false, path: dist, sourceMapFilename, libraryTarget: "commonjs2", filename: "[name].js", globalObject: "global", hashSalt }, resolve: { extensions: [".ts", ".js", ".scss", ".css"], // Resolve {N} system modules from tns-core-modules modules: [ resolve(dirname, "node_modules/tns-core-modules"), resolve(__dirname, "node_modules"), "node_modules/tns-core-modules", "node_modules", ], alias: { '~': appFullPath }, symlinks: true }, resolveLoader: { symlinks: false }, node: { // Disable node shims that conflict with NativeScript "http": false, "timers": false, "setImmediate": false, "fs": "empty", "dirname": false, }, devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"), optimization: { runtimeChunk: "single", splitChunks: { cacheGroups: { vendor: { name: "vendor", chunks: "all", test: (module, chunks) => { const moduleName = module.nameForCondition ? module.nameForCondition() : ''; return /[\/]node_modules[\/]/.test(moduleName) || appComponents.some(comp => comp === moduleName); }, enforce: true, }, } }, minimize: !!uglify, minimizer: [ new TerserPlugin({ parallel: true, cache: true, sourceMap: isAnySourceMapEnabled, terserOptions: { output: { comments: false, semicolons: !isAnySourceMapEnabled }, compress: { // The Android SBG has problems parsing the output // when these options are enabled 'collapse_vars': platform !== "android", sequences: platform !== "android", } } }) ], }, module: { rules: [ { test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), use: [ // Require all Android app components platform === "android" && { loader: "nativescript-dev-webpack/android-app-components-loader", options: { modules: appComponents } },

                {
                    loader: "nativescript-dev-webpack/bundle-config-loader",
                    options: {
                        angular: true,
                        loadCss: !snapshot, // load the application css if in debug mode
                        unitTesting,
                        appFullPath,
                        projectRoot,
                        ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
                    }
                },
            ].filter(loader => !!loader)
        },

        { test: /\.html$|\.xml$/, use: "raw-loader" },

        // tns-core-modules reads the app.css and its imports using css-loader
        {
            test: /[\/|\\]app\.css$/,
            use: [
                "nativescript-dev-webpack/style-hot-loader",
                { loader: "css-loader", options: { url: false } }
            ]
        },
        {
            test: /[\/|\\]app\.scss$/,
            use: [
                "nativescript-dev-webpack/style-hot-loader",
                { loader: "css-loader", options: { url: false } },
                "sass-loader"
            ]
        },

        // Angular components reference css files and their imports using raw-loader
        { test: /\.css$/, exclude: /[\/|\\]app\.css$/, use: "raw-loader" },
        { test: /\.scss$/, exclude: /[\/|\\]app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },

        {
            test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
            use: [
                "nativescript-dev-webpack/moduleid-compat-loader",
                "nativescript-dev-webpack/lazy-ngmodule-hot-loader",
                "@ngtools/webpack",
            ]
        },

        // Mark files inside `@angular/core` as using SystemJS style dynamic imports.
        // Removing this will cause deprecation warnings to appear.
        {
            test: /[\/\\]@angular[\/\\]core[\/\\].+\.js$/,
            parser: { system: true },
        },
    ],
},
plugins: [
    // Define useful constants like TNS_WEBPACK
    new webpack.DefinePlugin({
        "global.TNS_WEBPACK": "true",
        "process": "global.process",
    }),
    // Remove all files from the out dir.
    new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }),
    // Copy assets to out dir. Add your own globs as needed.
    new CopyWebpackPlugin([
        { from: { glob: "fonts/**" } },
        { from: { glob: "**/*.jpg" } },
        { from: { glob: "**/*.png" } },
    ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
    new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
    // For instructions on how to set up workers with webpack
    // check out https://github.com/nativescript/worker-loader
    new NativeScriptWorkerPlugin(),
    ngCompilerPlugin,
    // Does IPC communication with the {N} CLI to notify events when running in watch mode.
    new nsWebpack.WatchStateLoggerPlugin(),
],

};

if (report) { // Generate report files for bundles content config.plugins.push(new BundleAnalyzerPlugin({ analyzerMode: "static", openAnalyzer: false, generateStatsFile: true, reportFilename: resolve(projectRoot, "report", report.html), statsFilename: resolve(projectRoot, "report", stats.json), })); }

if (snapshot) { config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({ chunk: "vendor", angular: true, requireModules: [ "reflect-metadata", "@angular/platform-browser", "@angular/core", "@angular/common", "@angular/router", "nativescript-angular/platform-static", "nativescript-angular/router", ], projectRoot, webpackConfig: config, })); }

if (hmr) { config.plugins.push(new webpack.HotModuleReplacementPlugin()); }

return config; }; `

To Reproduce clone this project https://github.com/zeeshan-mehdi/driver-app

anikethsaha commented 5 years ago

My project was on cli version 5.3 i updated it to the latest cli version 6

which CLI ? webpack cli doesn't have any version more than 4.

zeeshan-mehdi commented 5 years ago

please check repository on this link this has all information https://github.com/zeeshan-mehdi/driver-app

anikethsaha commented 5 years ago

I am not sure whether this is the solution or not but it is a bug it seems the entry in the webpack config accepts a string or array of strings, but you have passed an object (https://github.com/zeeshan-mehdi/driver-app/blob/master/webpack.config.js#L62) , (https://github.com/zeeshan-mehdi/driver-app/blob/master/webpack.config.js#L123)

please refer the docs

Please let me know if this is working or not

PS: You can remove the code from your issue just keep the output as you have a repo for reference. Also I guess this is not a CLI issue it seems

zeeshan-mehdi commented 5 years ago

this is not the issue i have checked my other app is working with same webpack.config.js

anikethsaha commented 5 years ago

ok , yeah it can work ! can you please clarify this https://github.com/webpack/webpack-cli/issues/1077#issuecomment-529113754 Also, can you hardcode the entry path without using these variables and all? I think there must be some error with locating the entry file in these lines . https://github.com/zeeshan-mehdi/driver-app/blob/master/webpack.config.js#L60-L62

I am not sure how this nativescript-dev-webpack works and its uses. so anyone with experience with this can help you

evenstensberg commented 5 years ago

I think this would be best fit for stackOverflow as it looks like an issue non-related to the CLI itself. Happy to answer there if the question is specific and files are intented right along with a nice looking stack trace to make it readable.

goyote commented 4 years ago

Can you guys post your fixes?

zeeshan-mehdi commented 4 years ago

it was module import issue some modules were not getting resolved so thats why it was throwing this exception i just imported the modules and the app started working fine so it could be the problem in your case . thank you.