我正在跟踪一个有角度的项目,该项目的开始在https://github.com/pluralsight-projects/Angular-AlbumStoreProductPage上发布。
我对此进行了分叉,并在本地计算机(OS Windows 10)上进行了克隆。
该指南告诉我在package.json文件所在的根文件夹中运行以下命令:
执行最后一条命令时,我收到错误
'mocha' is not recognized as an internal or external command,
operable program or batch file.
node_modules appears empty, you may need to run `npm install`
我的node_modules文件夹确实是空的,我真的不知道为什么'npm install'不添加该文件夹。是的,在问这个问题之前,我先搜索了谷歌。 :)
请参阅我的命令提示符,在其中运行以下命令:
命令:
Microsoft Windows [Version 10.0.16299.547]
(c) 2017 Microsoft Corporation. All rights reserved.
C:\Users\kderous>d:
D:\>cd dev\angular\angular-albumstoreproductpage
D:\dev\Angular\Angular-AlbumStoreProductPage>dir
Volume in drive D is Data
Volume Serial Number is 3295-A0CE
Directory of D:\dev\Angular\Angular-AlbumStoreProductPage
02/09/2018 17:30 <DIR> .
02/09/2018 17:30 <DIR> ..
02/09/2018 17:26 1.247 .angular-cli.json
02/09/2018 17:26 258 .editorconfig
02/09/2018 17:26 619 .gitignore
02/09/2018 17:26 15 .npmrc
02/09/2018 17:26 7 .nvmrc
02/09/2018 17:35 961 3.0
02/09/2018 17:35 0 cd
02/09/2018 18:38 0 dir
02/09/2018 17:26 <DIR> e2e
02/09/2018 17:26 1.677 karma.conf.js
02/09/2018 17:35 0 npm
02/09/2018 17:26 517.785 package-lock.json
02/09/2018 17:26 4.076 package.json
02/09/2018 17:26 786 protractor.conf.js
02/09/2018 17:26 1.520 README.md
02/09/2018 17:26 <DIR> src
02/09/2018 17:26 405 tsconfig.json
02/09/2018 17:26 2.826 tslint.json
02/09/2018 17:35 0 type
02/09/2018 17:30 0 Your
18 File(s) 532.182 bytes
4 Dir(s) 406.178.123.776 bytes free
D:\dev\Angular\Angular-AlbumStoreProductPage>type package.json
{
"name": "pluralsight-project-build-an-album-store-product-page-with-angular",
"version": "0.0.2",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "./node_modules/.bin/mocha ./src/spec/mocha-specs --recursive --reporter spec & ng test --single-run",
"test:part2": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part2/ --recursive --reporter spec & ng test --single-run --part part2",
"test:part3": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part3/ --recursive --reporter spec & ng test --single-run --part part3",
"test:part4": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part4/ --recursive --reporter spec & ng test --single-run --part part4",
"test:part5": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part5/ --recursive --reporter spec & ng test --single-run --part part5",
"test:part6": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part6/ --recursive --reporter spec & ng test --single-run --part part6",
"test:part7": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part7/ --recursive --reporter spec & ng test --single-run --part part7",
"tutor-test": "./node_modules/.bin/mocha ./src/spec/mocha-specs --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run",
"tutor-test:part2": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part2/ --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run --part part2",
"tutor-test:part3": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part3/ --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run --part part3",
"tutor-test:part4": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part4/ --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run --part part4",
"tutor-test:part5": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part5/ --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run --part part5",
"tutor-test:part6": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part6/ --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run --part part6",
"tutor-test:part7": "./node_modules/.bin/mocha ./src/spec/mocha-specs/part7/ --recursive --reporter json & ng test --config tutor-karma.conf.js --single-run --part part7",
"mocha-spec": "./node_modules/.bin/mocha ./src/spec/mocha-specs/ --reporter spec",
"mocha-json": "./node_modules/.bin/mocha ./src/spec/mocha-specs/ --reporter json",
"karma-spec": "ng test --config tutor-karma.conf.js --single-run",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "5.2.0",
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.0",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"core-js": "2.4.1",
"rxjs": "5.5.6",
"zone.js": "0.8.12"
},
"devDependencies": {
"@angular/cli": "1.6.5",
"@angular/compiler-cli": "5.2.0",
"@angular/language-service": "5.2.0",
"@types/jasmine": "2.8.3",
"@types/jasminewd2": "2.0.2",
"@types/node": "6.0.60",
"bootstrap": "3.3.7",
"chai": "4.0.1",
"codelyzer": "4.0.1",
"cssom": "0.3.0",
"jasmine-core": "2.8.0",
"jasmine-spec-reporter": "4.2.1",
"jasmine2-custom-message": "0.8.2",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.2.1",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"karma-nightmare": "0.4.13",
"karma-spec-reporter": "0.0.31",
"karma-structured-json-reporter": "1.0.0",
"minimist": "1.2.0",
"mocha": "3.4.2",
"protractor": "5.1.2",
"ts-node": "4.1.0",
"tslint": "5.9.1",
"typescript": "2.5.3"
}
}
D:\dev\Angular\Angular-AlbumStoreProductPage>npm install
D:\dev\Angular\Angular-AlbumStoreProductPage>npm install -g @angular/cli@1.6.5
npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
C:\Users\kderous\AppData\Roaming\npm\ng -> C:\Users\kderous\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cli@1.6.5
updated 1 package in 57.762s
D:\dev\Angular\Angular-AlbumStoreProductPage>npm run test
'mocha' is not recognized as an internal or external command,
operable program or batch file.
node_modules appears empty, you may need to run `npm install`
D:\dev\Angular\Angular-AlbumStoreProductPage>dir
Volume in drive D is Data
Volume Serial Number is 3295-A0CE
Directory of D:\dev\Angular\Angular-AlbumStoreProductPage
02/09/2018 17:30 <DIR> .
02/09/2018 17:30 <DIR> ..
02/09/2018 17:26 1.247 .angular-cli.json
02/09/2018 17:26 258 .editorconfig
02/09/2018 17:26 619 .gitignore
02/09/2018 17:26 15 .npmrc
02/09/2018 17:26 7 .nvmrc
02/09/2018 17:35 961 3.0
02/09/2018 17:35 0 cd
02/09/2018 18:38 0 dir
02/09/2018 17:26 <DIR> e2e
02/09/2018 17:26 1.677 karma.conf.js
02/09/2018 17:35 0 npm
02/09/2018 17:26 517.785 package-lock.json
02/09/2018 17:26 4.076 package.json
02/09/2018 17:26 786 protractor.conf.js
02/09/2018 17:26 1.520 README.md
02/09/2018 17:26 <DIR> src
02/09/2018 17:26 405 tsconfig.json
02/09/2018 17:26 2.826 tslint.json
02/09/2018 17:35 0 type
02/09/2018 17:30 0 Your
18 File(s) 532.182 bytes
4 Dir(s) 406.178.123.776 bytes free
D:\dev\Angular\Angular-AlbumStoreProductPage>
如果您有任何建议,请告诉我。
谢谢!
答案 0 :(得分:0)
在package.json中添加"test": "nodemon --exec \"mocha -R min\""
答案 1 :(得分:0)
您应该在运行npm install
之后尝试运行npm install -g @angular/cli@1.6.5
。
答案 2 :(得分:0)
我自己找到了答案。
在我的项目中,似乎有一个.npmrc文件。 这将禁用“ npm install”命令的日志记录。
临时删除它后,我执行npm install并收到以下错误:
npm ERR! code ENOGIT
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\kderous\AppData\Roaming\npm-cache\_logs\2018-09-02T17_38_45_205Z-debug.log
我的问题是我没有在本地计算机上安装git。 安装git后,我的npm_install命令可以正常工作。