![](/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.