【发布时间】:2018-03-15 13:47:26
【问题描述】:
昨晚我的 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
更新:如果我创建一个新的 Angular 项目或解压缩从另一台计算机发送给我的项目,则可以正常工作。我能想到的唯一解释是路径搞砸了。
【问题讨论】:
标签: linux angular angular-cli