[英]Angular - CodeAnywhere - You seem to not be depending on “@angular/core”. This is an error
检查您是否在终端的项目文件夹中
first check the node 首先检查节点
node -v
and npm are install correctly 和npm已正确安装
npm -v
then try again with 然后再试一次
npm install -g npm@latest
then you add it in ts file 然后将其添加到ts文件中
const _core = require("@angular/core");
First ensure you have @angular/core
install, else run: 首先确保您已安装
@angular/core
,否则运行:
npm install @angular/core
This should get @angular/core
install in you node_module and also update itself in your package.json
. 这应该在您的node_module中安装
@angular/core
并在package.json
更新。 Also ensure that you're not using an old version of node and NPM, else run from your terminal: 还要确保您没有使用旧版本的节点和NPM,否则请从终端运行:
npm install npm@latest -g
Then you can add into your js file . 然后,您可以将其添加到js文件中。
const core_1 = require("@angular/core");
This is how I solved this problem on my machine. 这就是我在计算机上解决此问题的方式。
I first ran npm install @angular/core
. 我首先运行
npm install @angular/core
。
Then I ran npm install --save
. 然后我运行
npm install --save
。
When both installs had successfully completed I ran npm serve
and received an error saying 当两个安装都成功完成后,我运行了
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."
I then deleted my node_modules folder as well as my package-lock.json folder. 然后,我删除了node_modules文件夹以及package-lock.json文件夹。
After I deleted those folders I ran npm install --save
once more. 删除这些文件夹后,我再次运行
npm install --save
。
I ran npm start
and received another error. 我运行
npm start
并收到另一个错误。 This error said Error: Cannot find module '@angular-devkit/core'
. 该错误表示
Error: Cannot find module '@angular-devkit/core'
。
I ran npm install @angular-devkit/core --save
. 我跑了
npm install @angular-devkit/core --save
。
Finally, I ran npm start
and the project started! 最后,我运行了
npm start
,项目开始了!
There is some issue with node-sass in codeanywhere due to some permission exceptions. 由于某些权限异常,codeanywhere中的node-sass存在一些问题。 The workaround is go to /usr/lib/node_modules/@angular/cli/ and delete the node_modules folder and then run sudo npm install again create a new project using ng new and try running it .
解决方法是转到/ usr / lib / node_modules / @ angular / cli /并删除node_modules文件夹,然后运行sudo npm install再次使用ng new创建一个新项目并尝试运行它。 It will work
会工作的
Run npm install
inside this project folder to install all dependencies. 在该项目文件夹中运行
npm install
以安装所有依赖项。
Make sure you use the latest version of the CLI (upgrade guide below) 确保使用最新版本的CLI(下面的升级指南)
Run ng serve
to see the app in action (try npm start
in case ng serve
fails). 运行
ng serve
以查看应用程序的npm start
情况(如果ng serve
失败,请尝试npm start
)。
Run the below commands - only use "sudo" on Mac/ Linux. 运行以下命令-在Mac / Linux上仅使用“ sudo”。
sudo npm uninstall -g angular-cli @angular/cli
npm cache clean --force
sudo npm install -g @angular/cli
Delete 'node_modules' folder and 'package-lock.json' file from your project directory 从项目目录中删除“ node_modules”文件夹和“ package-lock.json”文件
Run the below commands in the given order 按给定顺序运行以下命令
npm install
npm install --save-dev @angular-devkit/build-angular
npm link
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.