angularjs - ng-serve 无法在 ubuntu 上运行

标签 angularjs node.js ubuntu-17.04

ng serve 
You seem to not be depending on "@angular/core". This is an error.

它给出了这个错误。

ls
hello-world  node_modules  package.json  package-lock.json

ng -v    

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.6.1
Node: 9.2.1
OS: linux x64
Angular: undefined
... 

@angular/cli: 1.6.1
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.6.2
webpack: 3.10.0

我尝试重新安装 npm 并清理缓存,但没有成功。

我的一些命令:

 5880  mkdir hello-world
 5881  cd hello-world
 5882  ng new hello-world
 5883  ng serve
 5884  sudo npm install
 5885  ng serve
 5886  ls
 5887  npm init
 5888  ls
 5889  ng serve
 5890  npm install
 5891  ng serve
 5892  npm install --save-dev @angular/cli@latest
 5893  ng serve
 5894  npm install\n
 5895  ng serve
 5896  npm i
 5897  ng serve
 5898  ls
 5899  sudo rm -rf  node_modules
 5900  em package-lock.json
 5901  rm package-lock.json
 5902  npm update
 5903  ng serve
 5904  ls
 5905  npm cache clean 
 5906  sudo npm cache clean 
 5907  sudo npm rebuild
 5908  ng serve
 5909  npm install
 5910  ng serve
 5911  ls
 5912  npm update
 5913  ls
 5914  ng serve
 5915  sudo npm install
 5916  ng serve
 5917  sudo npm update
 5918  ng serve
 5919  ls
 5920  cd
 5921  cd Projects/hello-world/
 5922  ng
 5923  ng -serve
 5924  ng -
 5925  ng -v
 5926  ls
 5927  vi node_modules
 5928  ls
 5929  npm cache clean --force\nnpm cache verify\nnpm i
 5930  ng -serve
 5931  s
 5932  ls
 5933  ng -v
 5934  npm init
 5935  ng -v
 5936  ng -serve
 5937  sudo npm uninstall -g @angular/cli
 5938  sudo npm install -g @angular/cli
 5939  ng serve
 5940  ls
 5941  ng -v

我想安装 angularcli,Angular 版本 1,但无法管理它。

最佳答案

我正在使用 agular cli 来创建和服务一个项目,编辑文件后它不会自动更新服务器,我遇到了这种同样的问题,所以使用了很多命令,但最后这个命令起作用了,我必须再次重新启动 ngserve

我尝试了 ngserveng build --watch ,两者都不起作用

重新安装 npm install ,我也检查了文件夹名称,但仍然无法正常工作

或者

在项目文件夹中执行以下命令:

"npm install --save @1.2.4"

npm startngserve

了解更多详情:- angular-cli issues

如果您使用的是 Ubuntu,则可以使用 sudo ngservesudo ngserve --watch

希望这有帮助!

关于angularjs - ng-serve 无法在 ubuntu 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47847547/

相关文章:

javascript - Angular ng-model 在 JS 中未定义

android - 使用 AngularJS 从服务器重定向时 Android 上的无限重定向循环

javascript - node.js 服务器端的监听器太多?

ubuntu - SceneBuilder 在启动时崩溃

javascript - 使用纯 AngularJs 附加元素

javascript - AngularJS 在屏幕之间发送值

javascript - 如何正确使用nodejs和javascript在mysql中存储blob数据

node.js - Angular2+Spring Boot : Unable to resolve context path issue | No data on frontend

python - 从 Python 中的 Flask 路由调用 Linux Powershell 中的 .ps1 脚本

c - 分配大量虚拟内存失败