node.js - npm install 命令后 Node_modules 文件夹为空
问题描述
我正在关注一个 Angular 项目,该项目的开始发布在https://github.com/pluralsight-projects/Angular-AlbumStoreProductPage。
我分叉了这个并在我的本地机器(OS windows 10)上进行了克隆。
该指南告诉我在 package.json 文件所在的根文件夹中运行以下命令:
- npm 安装
- npm install -g @angular/cli@1.6.5
- npm 运行测试
执行最后一个命令时,我收到错误
'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”不添加这个文件夹。是的,在问这个之前我先用谷歌搜索。:)
请参阅下面的命令提示符,我在其中运行以下命令:
- dir(显示我的项目根文件夹的文件夹,没有 node_modules 文件夹)
- 输入 package.json(仅供参考,我的 package.json 文件的内容)
- npm install (这里没有收到任何输出..)
- npm install -g @angular/cli@1.6.5
- npm run test(仅供参考,它失败了)
- dir(仅供参考,在安装 cmd 后向您显示我的文件夹中的目录,没有 node_modules 文件夹)
命令:
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>
如果您有任何建议,请告诉我。
提前致谢!
解决方案
我自己找到了答案。
在我的项目中,我似乎有一个 .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 命令工作正常。
推荐阅读
- javafx - 如何在 Scenebuilder 中添加一个网格,其中特定列的单元格比列的其余部分多?
- c# - Closedxml:无法下载文件并立即通过邮件发送
- matlab - 对非方阵使用 Surf 和 Peaks
- django - 如何测量我的 React Native 应用程序被使用的总时间
- python - 向量化矩阵和向量之间欧几里得距离的计算
- docker - 修复 docker-image-resource put 中的“无效参考格式”错误
- ruby - 红宝石命名约定
- javascript - 如何为动态下拉列表的每个循环设置 Ajax 调用和?
- r - 如何使用 R 中的特定词典对语料库进行词形还原?”
- c++ - 有人可以解释为什么程序显示 6 和 4 吗?