[英]You seem to not be depending on “@angular/core”. Typescript
I'm trying to run a command at npm start, but I get the message: "You seem to be not dependent on" @angular/core ". This is an error. What could be the reason? As it writes in the console: npm @angular/core -v it gets 5.4.2我试图在 npm start 上运行一个命令,但我收到消息:“你似乎不依赖于”@angular/core“。这是一个错误。可能是什么原因?正如它在控制台中所写的那样: npm @angular/core -v 它得到 5.4.2
My package.json我的 package.json
"dependencies": {
"@angular/animations": "^4.4.3",
"@angular/common": "^4.4.3",
"@angular/compiler": "^4.4.3",
"@angular/core": "^4.4.3",
"@angular/forms": "^4.4.3",
"@angular/http": "^4.4.3",
"@angular/platform-browser": "^4.4.3",
"@angular/platform-browser-dynamic": "^4.4.3",
"@angular/router": "^4.4.3",
"applicationinsights-js": "^1.0.12",
"core-js": "^2.4.1",
"date-fns": "^1.28.5",
"deepmerge": "^1.5.1",
"fingerprintjs2": "^1.5.1",
"ng2-page-scroll": "^4.0.0-beta.9",
"ngx-mydatepicker": "2.1.2",
"rxjs": "^5.1.0",
"zone.js": "^0.8.12"
},
"devDependencies": {
"@angular/cli": "^1.4.2",
"@angular/compiler-cli": "^4.4.3",
"@angular/language-service": "^4.4.3",
"@types/applicationinsights-js": "^1.0.4",
"@types/deepmerge": "^1.3.2",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"gulp": "^3.9.1",
"gulp-deploy-git": "^0.5.3",
"gulp-replace": "^0.6.1",
"husky": "^0.14.3",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"lint-staged": "^4.0.3",
"prettier": "^1.5.3",
"protractor": "^5.1.2",
"run-sequence": "^2.1.0",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "^2.5.2"
}
I encountered the same issue to resolve this all you need to do is to我遇到了同样的问题来解决这个问题,你需要做的就是
cd <project_name>
and then run the following command:然后运行以下命令:
npm update
and than the project will be succesfully compiled.然后项目将成功编译。
I have also faced the same issue while executing below command.在执行以下命令时,我也遇到了同样的问题。
D:\My_Project>ng serve
Then I have followed below steps and it worked for me.然后我按照以下步骤操作,它对我有用。
D:\My_Project>npm link
D:\My_Project>ng serve
Keep trying, good luck :)继续努力,祝你好运:)
Try to remove node_modules
folder, package-lock.json
file and then run:尝试删除
node_modules
文件夹、 package-lock.json
文件,然后运行:
npm cache clean --force
npm cache verify
npm i
This error occurred in my case when my node_modules folder is empty otherwise it will have bunch of folders inside.当我的 node_modules 文件夹为空时,会发生此错误,否则里面会有一堆文件夹。 I used the "ng link" command to work it out.
我使用“ng link”命令来解决它。
My project name is Pipes, and my command prompt looks like this:我的项目名称是 Pipes,我的命令提示符如下所示:
Pipes$ npm link管道 $ npm 链接
And finally you can execute ng serve to check it out最后你可以执行 ng serve 来检查它
You need to remove ^ this, because something its get that version where the others files are effecting due to this version,你需要删除^这个,因为它得到了那个版本,其他文件由于这个版本而影响,
so always use the specific version in angular.所以总是在 angular 中使用特定的版本。
or you can use the following package.json here:或者您可以在此处使用以下 package.json:
{
"name": "artist-booking-app",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "4.0.0",
"@angular/common": "4.0.0",
"@angular/compiler": "4.0.0",
"@angular/core": "4.0.0",
"@angular/forms": "4.0.0",
"@angular/http": "4.0.0",
"@angular/platform-browser": "4.0.0",
"@angular/platform-browser-dynamic": "4.0.0",
"@angular/router": "4.0.0",
"angular2-toaster": "^4.0.1",
"bootstrap": "3.3.7",
"core-js": "2.4.1",
"jquery": "3.2.1",
"ng2-scroll-to-el": "^1.0.0",
"primeng": "^4.1.3",
"rxjs": "5.4.1",
"zone.js": "0.8.14"
},
"devDependencies": {
"@angular/cli": "1.2.6",
"@angular/compiler-cli": "4.0.0",
"@angular/language-service": "4.0.0",
"@types/jasmine": "2.5.53",
"@types/jasminewd2": "2.0.2",
"@types/node": "6.0.60",
"codelyzer": "3.0.1",
"jasmine-core": "2.6.2",
"jasmine-spec-reporter": "4.1.0",
"karma": "1.7.0",
"karma-chrome-launcher": "2.1.1",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.2.1",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.1.2",
"ts-node": "3.0.4",
"tslint": "5.3.2",
"typescript": "2.3.3"
}
}
Run this:运行这个:
npm install @angular/core;
Then delete this file: node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__
然后删除这个文件:
node_modules/@angular/compiler-cli/ngcc/__ngcc_lock_file__
And try to reload your ng server.并尝试重新加载您的 ng 服务器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.