如果有人在2018年遇到这种情况,那么最终对我有效的方法是进入我用 ng new my-app创建的 my-app,然后运行 ng serve。这与它需要位于 my-app/package.json而不是 root/package.json的依赖项和 devDependency 有关。它们是两个独立的文件。
即使我将所有的依赖项复制到根文件夹的 package.json,我也必须进入并手动更改配置文件的路径位置,以便进入 my-app/*。进入 my-app/并在那里运行 ng serve,让它像预期的那样工作要容易得多。
"Versions of @angular/compiler-cli and typescript could not be determined.
The most common reason for this is a broken npm install.
Please make sure your package.json contains both @angular/compiler-cli and typescript in
devDependencies, then delete node_modules and package-lock.json (if you have one) and
run npm install again."
ashish@ashish-Inspiron-3521:~/Angular$ ng new FireStore
create FireStore/README.md (1025 bytes)
create FireStore/.angular-cli.json (1245 bytes)
create FireStore/.editorconfig (245 bytes)
create FireStore/.gitignore (544 bytes)
create FireStore/src/assets/.gitkeep (0 bytes)
create FireStore/src/environments/environment.prod.ts (51 bytes)
create FireStore/src/environments/environment.ts (387 bytes)
create FireStore/src/favicon.ico (5430 bytes)
create FireStore/src/index.html (296 bytes)
create FireStore/src/main.ts (370 bytes)
create FireStore/src/polyfills.ts (3114 bytes)
create FireStore/src/styles.css (80 bytes)
ashish@ashish-Inspiron-3521:~/Angular$ ng serve
You seem to not be depending on "@angular/core". This is an error.
我是怎么用 cmd 解决这个问题的
ashish@ashish-Inspiron-3521:~/Angular$ cd FireStore/
现在做 cmd
ashish@ashish-Inspiron-3521:~/Angular/FireStore$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **