nativescript-angular: Angular CLI generate results in 'Project is not configured for NativeScript, while --web is set to false'

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):

  • CLI: 7.0.0
  • Cross-platform modules: None
  • Android Runtime: None
  • iOS Runtime: None
  • Plugin(s): None
  • NativeScript-Angular: ~10.0.0
  • Angular: ~10.0.0

Describe the bug When generating a angular building block using the Angular CLI i get a message: Project is not configured for NativeScript, while --web is set to false

To Reproduce Create a new app from the empty 7.0.0 template tns create test-app --template @nativescript/template-blank-ng

Install the Angular CLI and Schematics as noted on the site Angular CLI npm i --save-dev @angular/cli npm i --save-dev @nativescript/schematics

Generate a module using the Angular CLI ng generate module test

Expected behavior A module names test.module.ts should be create in the folder.

Sample project No sample project.

Additional context This is done using a clean project created using the empty template and no additional work was done prio to this issue.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 8
  • Comments: 23

Most upvoted comments

It can be fixed by adding “nativescript” key in your package.json

package.json:

{
  ...
  "nativescript": {
    "id": "org.organization.app"
  },
  ...
}

Please, keep in mind that in previous versions “nativescript” key has more information than that, so you might need to add more info in order to keep other features working - what I am addressing here is just ng g c component command.

Btw - I started using Nativescript to build a new app just a few days ago and already have run into numerous problems with. In the beginning, I was VERY excited but it seems to almost be an abandoned project without anyone taking proper care of it, so just a word of advice from me - if you are here and try to use it in something else than a small project without a clear deadline I would strongly reconsider. Versioning is all over the place and you need to fix and patch things until it works, there is no clear instruction about what is the current way of doing things - some features are just broken and not working at all. I’m sticking with it just for the sake of my small hobby project.

@MegganKNaude Thanks, it worked, still need to:

Install:

Add

  "nativescript": {
    "id": "com.organizaton.app"
  }

Example

  "devDependencies": {
    "@angular/cli": "^10.1.7",
    "@angular/compiler-cli": "~10.1.0",
    "@nativescript/schematics": "^10.1.0",
    "@nativescript/types": "~7.0.0",
    "@nativescript/webpack": "~3.0.0",
    "@ngtools/webpack": "~10.1.0",
    "@schematics/angular": "^10.1.7",
    "tslint": "^6.1.3",
    "typescript": "^4.0.3"
  },
  "nativescript": {
    "id": "com.organizaton.app"
  }

Than run ng g c <Component name> --skip-import.

@martijnvanschie did you happen to find a solution to your secondary issue?

❯ ng g component tab2
Option "entryComponent" is deprecated: Since version 9.0.0 with Ivy, entryComponents is no longer necessary.
Cannot read property 'kind' of undefined

Solution that worked for me:

Updating the typescript devDependency from 3.9.0 to 4.0.3 and running ng g c [directory-name] --skip-import

Hi @martijnvanschie here’s an alternative extension https://marketplace.visualstudio.com/items?itemName=joshdsommer.vscode-add-angular-native-files. Would still like to fix the underlying issue