0

I'm getting familiar with NativeScript and I downloaded the following Angular-based NativeScript project from play.nativescript.org:

https://play.nativescript.org/?template=play-ng&id=Hqp5UQ&v=320

I opened a cmd prompt from the top-level directory that I downloaded and tried "ng serve." I don't remember the specific error but git bash instructed me to run the following cmd:

npm install --save-dev @angular/cli@latest

I tried "ng serve" again but then git bash returned the following error:

"Local workspace file ('angular.json') could not be found"

I googled this and found a thread on SO where someone mentioned to exec "ng update":

Error: Local workspace file ('angular.json') could not be found

So I did an "ng update" but now git bash returns an error:

"Error compiling schema", followed by a bunch of minified js followed by a red error message at the end "Unexpected token function"

Any idea what I might be missing here? What steps should I follow to get this up and running if I start over from scratch?

user9173787
  • 139
  • 1
  • 1
  • 4
  • Just a note: All playground projects can be directly deployed within few seconds using this app https://play.google.com/store/apps/details?id=org.nativescript.play&hl=bg and then you could change the code and upon save the changes will be synced on your device – Nick Iliev Aug 21 '18 at 13:59
  • If you want to play with NativeScript locally you will need to install the prerequisites - in that case follow the instuctions in the detailed answers below – Nick Iliev Aug 21 '18 at 14:00

2 Answers2

2

Like the other answerer pointed out -- the Angular CLI does not encompass everything that NativeScript is designed to do. For that they have their own CLI:

https://github.com/NativeScript/nativescript-cli

From my skimming of the docs above, it looks like this is the correct flow:

Install the CLI: npm install nativescript -g

Create a new app: tns create MyApp --template angular and then browse to the project cd MyApp

Add the platforms you care about: tns platform add android tns platform add ios

And then run your project: tns run ios tns run android


For a raw Angular project

You need to use the CLI to create a new project first.

ng new cool-app

This will create a new folder in your current directory with an empty Angular project. In order to use "ng serve" you first have to browse to that directory.

cd cool-app

Now that your are in the directory, the Angular CLI has enough context to boot your new app.

ng serve

Pearman
  • 1,068
  • 5
  • 14
0

Your don't use the angular cli project. So you are not be able to use commands like ng serve.

You can take a look here to see how to use a cli based project. angular cli quickstart

BTW. you use a project from nativescript play tool Wich is not actually support the cli commands (as you can see in the error there is no angular.json).

Either use a cli based project or configure your package.json to serve the current project. this question can help you.

billyjov
  • 2,778
  • 19
  • 35