昨晚出现的蓝色my ng serve命令开始出现此错误
bash: /usr/bin/ng: No such file or directory
从那以后我做了一些小事,我得到了以下内容 如果我卸载并使用
sudo npm install -g angular-cli
我收到错误
ng command not found
如果我卸载并使用
sudo npm install -g @angular/cli
编辑:在上面一行之后一切正常,但是当我运行ng serve
时,我收到以下错误(抱歉忘记添加此部分)
我得到了
The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
Error: The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
at Object.CompilerCliIsSupported (/usr/local/lib/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/ngtools_api.js:25:15)
at new AotPlugin (/usr/local/lib/node_modules/@angular/cli/node_modules/@ngtools/webpack/src/plugin.js:28:23)
at _createAotPlugin (/usr/local/lib/node_modules/@angular/cli/models/webpack-configs/typescript.js:92:16)
at Object.getNonAotConfig (/usr/local/lib/node_modules/@angular/cli/models/webpack-configs/typescript.js:100:19)
at NgCliWebpackConfig.buildConfig (/usr/local/lib/node_modules/@angular/cli/models/webpack-config.js:41:37)
at Class.run (/usr/local/lib/node_modules/@angular/cli/tasks/serve.js:71:98)
at check_port_1.checkPort.then.port (/usr/local/lib/node_modules/@angular/cli/commands/serve.js:123:26)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
我尝试在这个问题的唯一答案(bash /usr/bin/ng: No such file or directory in Angular)中遵循说明但是没有成功。
修改:ng -v
给出
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.7.3
Node: 8.2.1
OS: darwin x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.7.3
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
更新:如果我创建一个新的角度项目或解压缩从另一台计算机发送给我的服务工作。我能想到的唯一解释是,路径被搞砸了。
答案 0 :(得分:0)
使用命令
sudo npm install -g angular-cli
您在全局范围内安装了azure cli
的1.0版。你应该用
sudo npm uninstall -g angular-cli
我还会删除项目的node_modules
文件夹并运行npm install
进行全新安装。
如果这不起作用,我会尝试重新安装最新的azure cli
。
sudo npm uninstall -g @angular/cli
sudo npm cache verify
sudo npm install -g @angular/cli@latest