NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 196 forks source link

NS 7 with Angular application entry point not being found #5385

Open brookesb91 opened 4 years ago

brookesb91 commented 4 years ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project): ✔ Your ANDROID_HOME environment variable is set and points to correct directory. ✔ Your adb from the Android SDK is correctly installed. ✔ The Android SDK is installed. ✔ A compatible Android SDK for compilation is found. ✔ Javac is installed and is configured properly. ✔ The Java Development Kit (JDK) is installed and is configured properly. ✔ Xcode is installed and is configured properly. ✔ xcodeproj is installed and is configured properly. ✔ CocoaPods are installed. ✔ CocoaPods update is not required. ✔ CocoaPods are configured properly. ✔ Your current CocoaPods version is newer than 1.0.0. ✔ Python installed and configured correctly. ✔ The Python 'six' package is found. ✔ Xcode version 11.6.0 satisfies minimum required version 10. ✔ Getting NativeScript components versions information... ⚠ Update available for component nativescript. Your current version is 7.0.7-2020-09-09-185920-14263 and the latest available version is 7.0.7. ✔ Component @nativescript/core has 7.0.2 version and is up to date. ✖ Component @nativescript/ios is not installed. ✔ Component @nativescript/android has 7.0.0 version and is up to date.

Describe the bug

After upgrading a code sharing project with Angular to version 7 (using ns migrate) produces a project that results in the following errors being thrown when ns run android is run.

I noticed that during migration, the old tsconfig.tns.json is removed. Without this the project doesn't even start up and notes that a tsconfig file cannot be found. Adding back in my original tsconfig.tns.json file allows the compilation process to start but then throws up the aforementioned errors.

My tsconfig.tns.json

{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "module": "esNext",
    "target": "es2015",
    "moduleResolution": "node",
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "paths": {
      // Paths removed for clarity
    }
  },
  "files": ["apps/my-app/src/main.tns.ts"]
}

My nativescript.config.ts

// Identifiable names changed / removed
import { NativeScriptConfig } from '@nativescript/core';

export default {
  id: 'com.company.my-app',
  appResourcesPath: 'apps/my-app/App_Resources',
  android: {
    v8Flags: '--expose_gc --harmony_destructuring',
    markingMode: 'none',
  },
  appPath: 'apps/my-app/src',
  main: 'main.js',
  nsext: '.tns',
  webext: '',
  shared: true,
  useLegacyWorkflow: false,
  webpackConfigPath: './webpack.config.tns.js',
} as NativeScriptConfig;

It is worth noting that this project is included within a @nrwl/nx workspace and was working perfectly prior to the upgrade process.

rigor789 commented 4 years ago

@brookesb91 tsconfig.tns.json should not get removed in the latest version - what's in your package.json?

brookesb91 commented 4 years ago

@rigor789

{
  "name": "XXX",
  "version": "0.0.0",
  "license": "MIT",
  "graphdoc": {
    "endpoint": "http://localhost:3000/graphql",
    "output": "./public/doc/schema"
  },
  "scripts": {
    "android": "tns run android",
    "ios": "tns run ios",
    "mobile": "tns run",
    "preview": "tns preview",
    "ng": "nx",
    "nx": "nx",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "nx workspace-lint && ng lint",
    "e2e": "ng e2e",
    "affected:apps": "nx affected:apps",
    "affected:libs": "nx affected:libs",
    "affected:build": "nx affected:build",
    "affected:e2e": "nx affected:e2e",
    "affected:test": "nx affected:test",
    "affected:lint": "nx affected:lint",
    "affected:dep-graph": "nx affected:dep-graph",
    "affected": "nx affected",
    "format": "nx format:write",
    "format:write": "nx format:write",
    "format:check": "nx format:check",
    "update": "ng update @nrwl/workspace",
    "workspace-schematic": "nx workspace-schematic",
    "dep-graph": "nx dep-graph",
    "help": "nx help",
    "preinstall": "npx npm-force-resolutions",
    "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points && node ./decorate-angular-cli.js",
    "heroku-postinstall": "",
    "heroku-postbuild": "chmod a+x ./scripts/heroku.build.sh && ./scripts/heroku.build.sh",
    "copy-assets": "node scripts/copy-assets"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "10.0.0",
    "@angular/common": "10.0.0",
    "@angular/compiler": "10.0.0",
    "@angular/core": "10.0.0",
    "@angular/forms": "10.0.0",
    "@angular/google-maps": "^9.1.3",
    "@angular/platform-browser": "10.0.0",
    "@angular/platform-browser-dynamic": "10.0.0",
    "@angular/router": "10.0.0",
    "@angular/service-worker": "10.0.0",
    "@googlemaps/google-maps-services-js": "^2.5.5",
    "@nativescript/angular": "10.0.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/schematics": "^1.0.0",
    "@nativescript/theme": "~2.2.1",
    "@ngrx/effects": "9.1.0",
    "@ngrx/router-store": "9.1.0",
    "@ngrx/store": "9.1.0",
    "@ngx-loading-bar/core": "^4.2.0",
    "@ngx-loading-bar/http-client": "^4.2.0",
    "@nrwl/angular": "10.1.0",
    "apollo-angular": "^1.8.0",
    "apollo-angular-link-http": "^1.9.0",
    "apollo-cache-inmemory": "^1.6.0",
    "apollo-client": "^2.6.0",
    "apollo-link": "^1.2.11",
    "apollo-server": "^2.10.1",
    "apollo-server-express": "^2.10.1",
    "apollo-upload-server": "^7.1.0",
    "autoprefixer": "^9.7.4",
    "aws-sdk": "^2.673.0",
    "convict": "^5.2.0",
    "core-js": "^2.5.4",
    "dataloader": "^2.0.0",
    "dotenv": "^6.2.0",
    "express": "4.17.1",
    "express-graphql": "^0.9.0",
    "graphql": "^14.6.0",
    "graphql-iso-date": "^3.6.1",
    "graphql-resolvers": "^0.4.2",
    "graphql-tag": "^2.10.0",
    "graphql-tools": "^4.0.7",
    "in-app-purchase": "^1.11.4",
    "jsonwebtoken": "^8.5.1",
    "mkdirp": "^1.0.4",
    "mongoose": "^5.9.2",
    "mongoose-unique-validator": "^2.0.3",
    "morgan": "^1.9.1",
    "nativescript-carousel": "^6.1.1",
    "nativescript-geolocation": "^5.1.0",
    "nativescript-google-maps-sdk": "^2.9.1",
    "nativescript-onesignal-sdk": "^1.0.0",
    "nativescript-plugin-universal-links": "^1.0.2",
    "nativescript-purchase": "^2.0.13",
    "nativescript-social-share": "^1.6.0",
    "nodemailer": "^6.4.5",
    "onesignal-node": "^3.0.2",
    "passport": "^0.4.1",
    "postcss-import": "^12.0.1",
    "postcss-loader": "^3.0.0",
    "postcss-scss": "^2.0.0",
    "pug": "^2.0.4",
    "randomstring": "^1.1.5",
    "reflect-metadata": "~0.1.12",
    "rxjs": "6.5.5",
    "tailwindcss": "^1.2.0",
    "tns-core-modules": "^6.5.18",
    "tslib": "1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@2fd/graphdoc": "^2.4.0",
    "@angular-builders/custom-webpack": "^9.0.0",
    "@angular-devkit/build-angular": "0.1000.8",
    "@angular/cli": "10.0.8",
    "@angular/compiler-cli": "10.0.0",
    "@angular/language-service": "10.0.0",
    "@nativescript/schematics": "~1.0.0",
    "@nativescript/tslint-rules": "~0.0.5",
    "@nativescript/types": "7.0.0",
    "@nativescript/webpack": "~3.0.0",
    "@ngrx/store-devtools": "9.1.0",
    "@nrwl/cli": "9.1.2",
    "@nrwl/cypress": "10.1.0",
    "@nrwl/express": "10.1.0",
    "@nrwl/jest": "10.1.0",
    "@nrwl/node": "10.1.0",
    "@nrwl/nx": "^7.8.7",
    "@nrwl/workspace": "10.1.0",
    "@types/convict": "^4.2.1",
    "@types/dotenv": "^8.2.0",
    "@types/express": "^4.17.0",
    "@types/graphql-iso-date": "^3.3.3",
    "@types/graphql-resolvers": "^0.2.2",
    "@types/in-app-purchase": "^1.11.0",
    "@types/jest": "26.0.8",
    "@types/jsonwebtoken": "^8.3.7",
    "@types/mkdirp": "^1.0.0",
    "@types/mongoose": "^5.7.2",
    "@types/mongoose-unique-validator": "^1.0.3",
    "@types/morgan": "^1.7.37",
    "@types/node": "~8.9.4",
    "@types/nodemailer": "^6.4.0",
    "@types/passport": "^1.0.2",
    "@types/pug": "^2.0.4",
    "@types/randomstring": "^1.1.6",
    "codelyzer": "~5.0.1",
    "cypress": "^3.8.2",
    "eslint": "6.8.0",
    "eslint-plugin-cypress": "^2.10.3",
    "jest": "26.2.2",
    "jest-preset-angular": "8.2.1",
    "ngrx-store-freeze": "^0.2.4",
    "prettier": "2.0.4",
    "ts-jest": "26.1.4",
    "ts-node": "^7.0.1",
    "tslint": "6.0.0",
    "typescript": "3.9.7"
  },
  "resolutions": {
    "**/**/fs-capacitor": "^6.2.0"
  },
  "main": "main.js"
}
rigor789 commented 4 years ago

This is where tsconfig.tns.json is deleted if not in a shared project

https://github.com/NativeScript/nativescript-cli/blob/3f710eae6fce0c7ba8a45a3b5959d0bf04353e9d/lib/controllers/migrate-controller.ts#L801-L810

Wonder how it ended up being deleted in your project - because it does seem you have @nativescript/schematics in there.

Other than that, the main tsconfig.json is updated to es2017 etc. - but other configs are left untouched.

brookesb91 commented 4 years ago

This is where tsconfig.tns.json is deleted if not in a shared project

https://github.com/NativeScript/nativescript-cli/blob/3f710eae6fce0c7ba8a45a3b5959d0bf04353e9d/lib/controllers/migrate-controller.ts#L801-L810

Wonder how it ended up being deleted in your project - because it does seem you have @nativescript/schematics in there.

Other than that, the main tsconfig.json is updated to es2017 etc. - but other configs are left untouched.

No idea either, but it happens when running ns migrate and leaves just the new nativescript.config.ts. Even when adding the tsconfig back in, I'm still faced with the entry point was not found issue.

offline-pixel commented 3 years ago

Maybe i am facing the same issue, after ng add @nativescript/angular

my package.json

{
  "name": "college-house-enterprise-area-terminal",
  "version": "0.0.0",
  "author": "Deepak Ranolia",
  "scripts": {
    "android": "ns run android --no-hmr",
    "ios": "ns run ios --no-hmr",
    "mobile": "ns run",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@nativescript/angular": "~10.1.0",
    "@nativescript/core": "~7.0.0",
    "@nativescript/theme": "~2.5.0",
    "reflect-metadata": "~0.1.12",
    "tslib": "^2.0.0",
    "@angular/animations": "~10.0.11",
    "@angular/common": "~10.0.11",
    "@angular/compiler": "~10.0.11",
    "@angular/core": "~10.0.11",
    "@angular/forms": "~10.0.11",
    "@angular/platform-browser": "~10.0.11",
    "@angular/platform-browser-dynamic": "~10.0.11",
    "@angular/router": "~10.0.11",
    "rxjs": "~6.5.5",
    "zone.js": "~0.10.3"
  },
  "devDependencies": {
    "@nativescript/webpack": "~3.0.0",
    "@nativescript/tslint-rules": "~0.0.5",
    "@angular-devkit/build-angular": "~0.1000.7",
    "@angular/cli": "~10.0.7",
    "@angular/compiler-cli": "~10.0.11",
    "@nativescript/schematics": "^11.0.0",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  },
  "main": "main.tns.js"
}

my tsconfig.json

/*

  This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience.
  It is not intended to be used to perform a compilation.

  To learn more about this file see: https://angular.io/config/solution-tsconfig.
*/
{
  "files": [],
  "references": [
    {
      "path": "./tsconfig.app.json"
    },
    {
      "path": "./tsconfig.spec.json"
    }
  ]
}

tsconfig.app.json

{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": [],
    "paths": {
      "@src/*": [
        "src/*.web",
        "src/*"
      ]
    }
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts",
    "src/main.ts",
    "src/polyfills.ts"
  ]
}

tsconfig.spec.json

/* To learn more about this file see: https://angular.io/config/tsconfig. */
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
  "extends": "./tsconfig.base.json",
  "compilerOptions": {
    "outDir": "./out-tsc/spec",
    "types": [
      "jasmine"
    ]
  },
  "files": [
    "src/test.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.spec.ts",
    "src/**/*.d.ts"
  ]
}

and i am getting the error after i scan the QR code

Local plugin @nativescript/core differs in major version from plugin in preview app. The local plugin has version ~7.0.0 and the plugin in preview app has version 6.5.0. Some features might not work as expected.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*                                                                                                                                   *
*  In the app are used one or more NativeScript plugins with native dependencies.                                                   *
*  Those plugins will not work while building the project via `$ tns preview`. Please, use `$ tns run <platform>` command instead.  *
*                                                                                                                                   *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Preparing project...
/home/project-path/project-name/node_modules/webpack-cli/bin/cli.js:93
                                throw err;
                                ^

Error: The specified path to app directory /home/project-path/project-name/app does not exist. Unable to find entry module.
    at verifyEntryModuleDirectory (/home/project-path/project-name/node_modules/@nativescript/webpack/index.js:220:15)
    at Object.exports.getEntryModule (/home/project-path/project-name/node_modules/@nativescript/webpack/index.js:77:5)
    at module.exports (/home/project-path/project-name/webpack.config.js:99:36)
    at handleFunction (/home/project-path/project-name/node_modules/webpack-cli/bin/utils/prepareOptions.js:21:13)
    at prepareOptions (/home/project-path/project-name/node_modules/webpack-cli/bin/utils/prepareOptions.js:9:5)
    at requireConfig (/home/project-path/project-name/node_modules/webpack-cli/bin/utils/convert-argv.js:117:14)
    at /home/project-path/project-name/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
    at Array.forEach (<anonymous>)
    at module.exports (/home/project-path/project-name/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
    at /home/project-path/project-name/node_modules/webpack-cli/bin/cli.js:71:45
    at Object.parse (/home/project-path/project-name/node_modules/yargs/yargs.js:576:18)
    at /home/project-path/project-name/node_modules/webpack-cli/bin/cli.js:49:8
    at Object.<anonymous> (/home/project-path/project-name/node_modules/webpack-cli/bin/cli.js:366: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> (/home/project-path/project-name/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

Please let me know for suitable solutions as i am unable to find anything at all

FYI: main.tns.ts

// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { platformNativeScriptDynamic } from '@nativescript/angular';

import { AppModule } from '@src/app/src/app.module';

// A traditional NativeScript application starts by initializing global objects,
// setting up global CSS rules, creating, and navigating to the main page.
// Angular applications need to take care of their own initialization: modules, components, directives, routes, DI providers.
// A NativeScript Angular app needs to make both paradigms work together,
// so we provide a wrapper platform object, platformNativeScriptDynamic,
// that sets up a NativeScript application and can bootstrap the Angular framework.
platformNativeScriptDynamic().bootstrapModule(AppModule);
offline-pixel commented 3 years ago

++ i updated package.json file as i was unable to genrate the QR code before


  "nativescript": {
    "id": "org.nativescript.ngsample",
    "tns-android": {
      "version": "6.5.3"
    }
  }

However, after this it throw err

JimLynchCodes commented 1 year ago

I'm getting this error too. Can't seem to find any way to run the examples here: https://github.com/ProgressNS/nativescript-ui-samples-angular