![](/img/trans.png)
[英]You seem to not be depending on “@angular/core”. This is an error
[英]Angular - CodeAnywhere - You seem to not be depending on “@angular/core”. This is an error
检查您是否在终端的项目文件夹中
首先检查节点
node -v
和npm已正确安装
npm -v
然后再试一次
npm install -g npm@latest
然后将其添加到ts文件中
const _core = require("@angular/core");
首先确保您已安装@angular/core
,否则运行:
npm install @angular/core
这应该在您的node_module中安装@angular/core
并在package.json
更新。 还要确保您没有使用旧版本的节点和NPM,否则请从终端运行:
npm install npm@latest -g
然后,您可以将其添加到js文件中。
const core_1 = require("@angular/core");
这就是我在计算机上解决此问题的方式。
我首先运行npm install @angular/core
。
然后我运行npm install --save
。
当两个安装都成功完成后,我运行了npm 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."
然后,我删除了node_modules文件夹以及package-lock.json文件夹。
删除这些文件夹后,我再次运行npm install --save
。
我运行npm start
并收到另一个错误。 该错误表示Error: Cannot find module '@angular-devkit/core'
。
我跑了npm install @angular-devkit/core --save
。
最后,我运行了npm start
,项目开始了!
由于某些权限异常,codeanywhere中的node-sass存在一些问题。 解决方法是转到/ usr / lib / node_modules / @ angular / cli /并删除node_modules文件夹,然后运行sudo npm install再次使用ng new创建一个新项目并尝试运行它。 会工作的
在该项目文件夹中运行npm install
以安装所有依赖项。
确保使用最新版本的CLI(下面的升级指南)
运行ng serve
以查看应用程序的npm start
情况(如果ng serve
失败,请尝试npm start
)。
运行以下命令-在Mac / Linux上仅使用“ sudo”。
sudo npm uninstall -g angular-cli @angular/cli
npm cache clean --force
sudo npm install -g @angular/cli
从项目目录中删除“ node_modules”文件夹和“ package-lock.json”文件
按给定顺序运行以下命令
npm install
npm install --save-dev @angular-devkit/build-angular
npm link
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.