嗨,我在使用npm命令时遇到问题,无论我尝试什么,都遇到命令错误,无论我尝试ng服务如何,都遇到错误
在客户端中找不到模块@ angular-devkit / build-angular 所以我尝试安装@ angular-devkit / build-angular,然后出现波纹管错误
npm错误!文件C:\ Users \ Mohnish Miri \ source \ repos \ ARCAngular \ ARCAngular \ ClientApp \ package.json npm ERR!代码EJSONPARSE npm ERR! JSON.parse无法解析json npm ERR! JSON.parse意外的令牌/位于JSON中的位置1415,同时在'... endendencies'附近进行解析: npm ERR! JSON.parse ///“ @ angular-builders ...” npm ERR! JSON.parse无法解析package.json数据。 npm ERR! JSON.parse package.json必须是实际的JSON,而不仅仅是JavaScript。
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Mohnish Miri\AppData\Roaming\npm-cache\_logs\2019-03-08T10_37_20_315Z-debug.log
这是日志文件
0 info it worked if it ends with ok
1 verbose cli [ 'G:\\Node\\node.exe',
1 verbose cli 'G:\\Node\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--no-cache' ]
2 info using npm@6.4.1
3 info using node@v10.15.0
4 verbose npm-session f9ccfd416a935a47
5 silly install runPreinstallTopLevelLifecycles
6 silly install loadCurrentTree
7 silly install readLocalPackageData
8 timing stage:rollbackFailedOptional Completed in 2ms
9 timing stage:runTopLevelLifecycles Completed in 1522ms
10 verbose stack Error: Failed to parse json
10 verbose stack Unexpected token / in JSON at position 0 while parsing near '//{
10 verbose stack // "name": "ARC...'
10 verbose stack at parseError (G:\Node\node_modules\npm\node_modules\read-package-json\read-json.js:452:11)
10 verbose stack at parseJson (G:\Node\node_modules\npm\node_modules\read-package-json\read-json.js:104:26)
10 verbose stack at G:\Node\node_modules\npm\node_modules\read-package-json\read-json.js:51:5
10 verbose stack at G:\Node\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16
10 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
11 verbose cwd C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp
12 verbose Windows_NT 10.0.17134
13 verbose argv "G:\\Node\\node.exe" "G:\\Node\\node_modules\\npm\\bin\\npm-cli.js" "install" "--no-cache"
14 verbose node v10.15.0
15 verbose npm v6.4.1
16 error file C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\package.json
17 error code EJSONPARSE
18 error JSON.parse Failed to parse json
18 error JSON.parse Unexpected token / in JSON at position 0 while parsing near '//{
18 error JSON.parse // "name": "ARC...'
19 error JSON.parse Failed to parse package.json data.
19 error JSON.parse package.json must be actual JSON, not just JavaScript.
20 verbose exit [ 1, true ]
这是我的pakjage.json文件
{
"name": "ARCAngular",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "npm run build -- --app=ssr --output-hashing=media",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular-devkit/schematics-cli": "^0.13.5",
"@angular/animations": "7.2.8",
"@angular/cli": "^7.3.5",
"@angular/common": "7.2.8",
"@angular/compiler": "7.2.8",
"@angular/core": "7.2.8",
"@angular/forms": "7.2.8",
"@angular/http": "7.2.8",
"@angular/platform-browser": "7.2.8",
"@angular/platform-browser-dynamic": "7.2.8",
"@angular/platform-server": "7.2.8",
"@angular/router": "7.2.8",
"@ng-bootstrap/ng-bootstrap": "^4.1.0",
"@nguniversal/aspnetcore-engine": "^7.1.1",
"@nguniversal/module-map-ngfactory-loader": "^7.1.1",
"acorn": "^6.1.1",
"angular2-uuid": "^1.1.1",
"angularjs-datepicker": "^2.1.23",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.3.1",
"core-js": "^2.6.5",
"jquery": "^3.3.1",
"ngx-bootstrap": "^3.2.0",
"popper.js": "^1.14.7",
"rxjs": "^6.4.0",
"rxjs-compat": "^6.4.0",
"tslib": "^1.9.3",
"webpack": "^4.29.6",
"webpack-combine-loaders": "^2.0.4",
"webpack-dev-server": "^3.2.1",
"zone.js": "~0.8.29"
},
"devDependencies": {
//"@angular-builders/custom-webpack": "^7.0.0",
//"@angular-builders/dev-server": "^7.0.0",
"@angular-devkit/build-angular": "^0.13.5",
"@angular/compiler-cli": "7.2.8",
"@angular/language-service": "7.2.8",
"@types/jasmine": "^3.3.9",
"@types/jasminewd2": "~2.0.6",
"@types/node": "^10.12.30",
"codelyzer": "^4.5.0",
"jasmine-core": "~3.3.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.0.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.2",
"ts-node": "^8.0.3",
"tslint": "~5.12.1",
"typescript": "3.2.4"
},
"optionalDependencies": {
"node-sass": "^4.9.0"
}
}
从此开始
//"@angular-builders/custom-webpack": "^7.0.0",
//"@angular-builders/dev-server": "^7.0.0",
我尝试将它们直接安装在package.json中 我只能使用一个命令
npm install @angular/cli
(or)
npm Uninstall @angular/cli
我尝试了所有以前没有用的解决方案
和
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.entry should be one of these:
function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
-> The entry point(s) of the compilation.
Details:
* configuration.entry should be an instance of function
-> A Function returning an entry object, an entry string, an entry array or a promise to these things.
* configuration.entry['styles'] should be a string.
-> The string is resolved to a module which is loaded upon startup.
* configuration.entry['styles'] should not contain the item 'C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\bootstrap\dist\css\bootstrap.min.css' twice.
* configuration.entry should be a string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup.
* configuration.entry should be an array:
[non-empty string]
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.entry should be one of these:
function | object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string]
-> The entry point(s) of the compilation.
Details:
* configuration.entry should be an instance of function
-> A Function returning an entry object, an entry string, an entry array or a promise to these things.
* configuration.entry['styles'] should be a string.
-> The string is resolved to a module which is loaded upon startup.
* configuration.entry['styles'] should not contain the item 'C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\bootstrap\dist\css\bootstrap.min.css' twice.
* configuration.entry should be a string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup.
* configuration.entry should be an array:
[non-empty string]
at webpack (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\webpack\lib\webpack.js:31:9)
at Observable.rxjs_1.Observable.obs [as _subscribe] (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-webpack\src\webpack-dev-server\index.js:39:37)
at Observable._trySubscribe (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-webpack\node_modules\rxjs\internal\Observable.js:44:25)
at Observable.subscribe (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-webpack\node_modules\rxjs\internal\Observable.js:30:22)
at C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\util\subscribeToObservable.js:10:20
at Object.subscribeToResult (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\util\subscribeToResult.js:10:45)
at MergeMapSubscriber._innerSub (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\mergeMap.js:82:29)
at MergeMapSubscriber._tryNext (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\mergeMap.js:76:14)
at MergeMapSubscriber._next (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\mergeMap.js:59:18)
at MergeMapSubscriber.Subscriber.next (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\Subscriber.js:67:18)
at TapSubscriber._next (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\tap.js:65:26)
at TapSubscriber.Subscriber.next (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\Subscriber.js:67:18)
at MergeMapSubscriber.notifyNext (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\operators\mergeMap.js:92:26)
at InnerSubscriber._next (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\InnerSubscriber.js:28:21)
at InnerSubscriber.Subscriber.next (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\Subscriber.js:67:18)
at SafeSubscriber.__tryOrUnsub (C:\Users\Mohnish Miri\source\repos\ARCAngular\ARCAngular\ClientApp\node_modules\@angular-devkit\architect\node_modules\rxjs\internal\Subscriber.js:209:16)`
答案 0 :(得分:0)
删除//
注释包中的行:
//"@angular-builders/custom-webpack": "^7.0.0",
//"@angular-builders/dev-server": "^7.0.0",
如果需要在package.json
中发表评论,请使用此选项:https://www.npmjs.com/package/x----x----x
最终输出如下:
//"x----x----x": "@angular-builders/custom-webpack, ^7.0.0",
//"x----x----x": "@angular-builders/dev-server, ^7.0.0",
然后,当您想重新添加这些软件包时,可以将它们转换回列表中的普通软件包。在此之前,包“ {x----x----x
”基本上使它们成为注释。