【问题标题】:Runs a code I got written in angular js and gets an error message that I can't resolve运行我用 Angular js 编写的代码并收到一条我无法解决的错误消息
【发布时间】:2021-08-26 05:56:52
【问题描述】:

当我尝试运行 ng serve 我得到: “serve 命令需要在 Angular 项目中运行,但找不到项目定义”。

我已经尝试了一些命令,例如:

npm 缓存清理 --force npm install -g @angular/cli

ng update @angular/core --migrate-only --from=1.9.0 --allow-dirty --force
1>npm 链接打字稿
npm 卸载 -g @angular/cli@
npm 卸载 -g @angular/core
ng update @angular/cli @angular/core --allow-dirty --force
npm install -g @angular/cli@latest
npm install -g @angular/core@latest
npm install --save-dev @angular/core@latest

我尝试删除 node_modules 和 pakage-lock.json 然后“npm i”

当我尝试时仍然如此; ng serve 我明白了:

"The serve command requires to be run in an Angular project, but a project definition could not be found."

这里附上packeg jason的图片:
和终端图片:

我能做什么? 谢谢

【问题讨论】:

  • 你添加了两次终端的图片,错过了package.json。为了安全起见,您在 package.json 所在的同一目录中运行 ng serve 命令?

标签: node.js angularjs angular npm


【解决方案1】:

尝试首先检查并安装 Angular Cli,然后运行以下命令

  1. npm install -g @angular/cli
  2. ng new my-angular-project
  3. cd my-angular-project
  4. ng 服务 --open

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-23
    • 2021-04-21
    • 2018-05-23
    • 1970-01-01
    • 2020-07-08
    • 1970-01-01
    相关资源
    最近更新 更多