我刚刚通过运行npm update更新了我的角度2应用程序,不幸的是我的应用程序不再运行,尽管终端中没有显示错误,我的控制台中有很多错误。无论如何我可以撤销更新吗?
//错误
The stylesheet http://localhost:4200/app/assets/js/jquery.min.js was not loaded because its MIME type, “application/javascript”, is not “text/css”. localhost:4200
GET
http://localhost:4200/node_modules/zone.js/dist/zone.js [HTTP/1.1 404 Not Found 5ms]
GET
http://localhost:4200/systemjs.config.js [HTTP/1.1 404 Not Found 8ms]
ReferenceError: System is not defined[Learn More] localhost:4200:29:5
TypeError: f is undefined[Learn More] scripts.bundle.js%20line%2034%20%3E%20eval:15:3
Unhandled Promise rejection: Failed to load ../bootstrap/css/bootstrap.min.css ; Zone: <root> ; Task: Promise.then ; Value: Failed to load ../bootstrap/css/bootstrap.min.css undefined vendor.bundle.js:129451:13
Object { __zone_symbol__error: Error, fileName: Getter, lineNumber: Getter, columnNumber: Getter, message: Getter, name: Getter, stack: Getter, originalStack: Getter, zoneAwareStack: Getter, toString: createMethodProperty/props[key].value(), 5 more… } vendor.bundle.js:129453:9
//的package.json
{
"name": "project",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "~2.4.8",
"@angular/compiler": "~2.4.8",
"@angular/core": "~2.4.8",
"@angular/forms": "~2.4.8",
"@angular/http": "~2.4.8",
"@angular/platform-browser": "~2.4.8",
"@angular/platform-browser-dynamic": "~2.4.8",
"@angular/router": "~3.4.8",
"@types/lodash": "^4.14.50",
"angular-2-data-table": "^0.1.2",
"angular2-datatable": "^0.5.2",
"core-js": "^2.4.1",
"lodash": "^4.17.4",
"ng2-date-picker": "^0.2.1",
"ng2-file-upload": "^1.2.0",
"ng2-modal": "0.0.25",
"ng2-pagination": "^2.0.1",
"primeng": "^2.0.1",
"rxjs": "5.2.0",
"tinymce": "^4.5.2",
"ts-helpers": "^1.1.1",
"zone.js": "^0.7.7"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"@types/node": "^7.0.5",
"angular-cli": "1.0.0-beta.28.3",
"codelyzer": "3.0.0-beta.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "3.2.0",
"karma": "1.5.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.6.0",
"protractor": "5.1.1",
"ts-node": "2.1.0",
"tslint": "4.4.2",
"typescript": "~2.2.1"
}
}
答案 0 :(得分:5)
删除 node_modules 目录
从您的版本恢复以前的 package.json 文件 控制系统
运行 npm install
您还可以删除并重新创建 dist 或生成的文件文件夹并重建。
编辑:您可以尝试以@msanford的方式更新软件包,但请注意,有时它仍会升级到不兼容的版本。我总是尝试使用维护良好的种子版本的包已知可以很好地协同工作。特别适用于zonejs。
答案 1 :(得分:3)
如果您认为应该更新已安装的节点模块,并且未修改,则package.json
进入package.json并(暂时)删除{{1版本号之前的{}和^
;再试一次~
。
这将指示npm安装指定的确切修补程序版本,并且不会尝试将其升级到最新的修补程序(npm install
)或最新的次要(~
)版本。
当您运行^
时,告诉npm去获取您指定的每个软件包的最新版本,最多允许最新的补丁/次要,如〜所示或^。您可能已经通过这种方式引入了不兼容性。
如果您更改了npm update
文件,Ben的建议是合适的,如果您这样做,请尝试他的建议。