[英]how can I get this angular project up and running?
I'm getting familiar with NativeScript and I downloaded the following Angular-based NativeScript project from play.nativescript.org: 我熟悉NativeScript,并从play.nativescript.org下载了以下基于Angular的NativeScript项目:
https://play.nativescript.org/?template=play-ng&id=Hqp5UQ&v=320 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." 我从下载的顶级目录中打开了一个cmd提示符,然后尝试“ ng serve”。 I don't remember the specific error but git bash instructed me to run the following cmd:
我不记得具体的错误,但是git bash指示我运行以下cmd:
npm install --save-dev @angular/cli@latest
I tried "ng serve" again but then git bash returned the following error: 我再次尝试了“ ng serve”,但是git bash返回了以下错误:
"Local workspace file ('angular.json') could not be found"
“找不到本地工作区文件('angular.json')”
I googled this and found a thread on SO where someone mentioned to exec "ng update": 我用谷歌搜索并在SO上找到一个线程,其中有人提到要执行“ ng update”:
Error: Local workspace file ('angular.json') could not be found 错误:找不到本地工作区文件('angular.json')
So I did an "ng update" but now git bash returns an error: 所以我做了一个“ ng update”,但是现在git bash返回一个错误:
"Error compiling schema", followed by a bunch of minified js followed by a red error message at the end "Unexpected token function"
“错误编译模式”,其后是一堆缩小的js,在“意外令牌功能”末尾带有红色错误消息
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. 就像其他答复者指出的那样-Angular CLI并未涵盖NativeScript设计要完成的所有工作。 For that they have their own CLI:
为此,它们具有自己的CLI:
https://github.com/NativeScript/nativescript-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
安装CLI:
npm install nativescript -g
Create a new app: tns create MyApp --template angular
and then browse to the project cd MyApp
创建一个新的应用程序:
tns create MyApp --template angular
,然后浏览到项目cd MyApp
Add the platforms you care about: tns platform add android
tns platform add ios
添加您关心的平台:
tns platform add android
tns platform add ios
And then run your project: tns run ios
tns run android
然后运行您的项目:
tns run ios
tns run android
For a raw Angular project 对于原始的Angular项目
You need to use the CLI to create a new project first. 您需要先使用CLI创建一个新项目。
ng new cool-app
This will create a new folder in your current directory with an empty Angular project. 这将在当前目录中创建一个带有空Angular项目的新文件夹。 In order to use "ng serve" you first have to browse to that directory.
为了使用“ ng serve”,您首先必须浏览到该目录。
cd cool-app
Now that your are in the directory, the Angular CLI has enough context to boot your new app. 现在您已经在目录中,Angular CLI具有足够的上下文来启动新应用程序。
ng serve
Your don't use the angular cli project. 您不要使用angular cli项目。 So you are not be able to use commands like
ng serve
. 因此,您将无法使用
ng serve
类的命令。
You can take a look here to see how to use a cli based project. 您可以在这里看看如何使用基于cli的项目。 angular cli quickstart
角度cli快速入门
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
). 您使用nativescript播放工具中的项目Wich实际上并不支持cli命令(如您在错误中看到的那样,没有
angular.json
)。
Either use a cli based project or configure your package.json
to serve the current project. 使用基于cli的项目或配置
package.json
以服务当前项目。 this question can help you. 这个问题可以帮助您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.