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?
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.