Jquery 不能在 angular 6 中工作错误:ENOENT:没有这样的文件或目录,打开'...\node_modules\jquery\dist\jquery.min.js' [英] Jquery not working in angular 6 Error: ENOENT: no such file or directory, open '...\node_modules\jquery\dist\jquery.min.js'
问题描述
我正在将 Angular 5 项目迁移到 Angular 6.
I am in process migrating Angular 5 project to Angular 6.
在开始申请时
npm start
出现以下错误
** Angular Live Development Server is listening on localhost: 9000,
open your browser on http://localhost:9000/ **
91% additional asset processing scripts-webpack-plugin× 「wdm」:
Error: ENOENT: no such file or directory,open'\trunk\node_modules\jquery\dist\jquery.min.js'
我试过了
npm install jquery --save
npm install @types/jquery --save
没有任何效果
我检查了我的节点模块文件夹,我可以看到 jquery 文件
I checked my node modules folder I can able to see the jquery file
在下面粘贴了我的 package.json 和 angular.json
Pasted my package.json and angular.json below
package.json
package.json
"dependencies": {
"@angular/animations": "^6.0.0",
"@angular/common": "^6.0.0",
"@angular/compiler": "^6.0.0",
"@angular/core": "^6.0.0",
"@angular/forms": "^6.0.0",
"@angular/http": "^6.0.0",
"@angular/platform-browser": "^6.0.0",
"@angular/platform-browser-dynamic": "^6.0.0",
"@angular/router": "^6.0.0",
"@ng-bootstrap/ng-bootstrap": "^2.0.0",
"bootstrap": "^4.1.1",
"core-js": "^2.5.4",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"@types/jquery": "^3.3.1",
"popper.js": "^1.14.3",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.0",
"@angular-devkit/build-angular": "~0.6.0",
"typescript": "~2.7.2",
"@angular/cli": "~6.0.0",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
angular.json
angular.json
"styles": [
"src/styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"./assets/css/font-icon.css",
"../node_modules/font-awesome/css/font-awesome.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
]
请帮我解决这个问题.
推荐答案
angular 团队再次无缘无故地让事情变得更难 =(
Once again the angular team makes things harder for not real reason =(
我遇到了这个问题,在谷歌搜索无果之后,我想知道他们是否以某种方式改变了相对路径以及重命名了 angular-cli.json.
I had this problem and after Googling around fruitlessly I wondered if they had changed relative paths somehow as well as renaming angular-cli.json.
在文件的更深处,我发现了这一行:
A little further up in the file I found the line:
是的,只需更改:
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
到
"./node_modules/jquery/dist/jquery.js",
"./node_modules/tether/dist/js/tether.js",
"./node_modules/bootstrap/dist/js/bootstrap.js"
这篇关于Jquery 不能在 angular 6 中工作错误:ENOENT:没有这样的文件或目录,打开'...\node_modules\jquery\dist\jquery.min.js'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!