简体   繁体   English

npm install 命令后 node_modules 文件夹为空

[英]Node_modules folder is empty after npm install command

I'm following an angular project where the start of the project is published at https://github.com/pluralsight-projects/Angular-AlbumStoreProductPage .我正在关注一个 angular 项目,该项目的开始发布在https://github.com/pluralsight-projects/Angular-AlbumStoreProductPage

I forked this and made a clone on my local machine (OS windows 10).我分叉了这个并在我的本地机器(操作系统 Windows 10)上进行了克隆。

The guide tells me to run the following commands in the root folder, where the package.json file is located:该指南告诉我在 package.json 文件所在的根文件夹中运行以下命令:

  • npm install安装
  • npm install -g @angular/cli@1.6.5 npm install -g @angular/cli@1.6.5
  • npm run test npm 运行测试

When executing the last command I receive the error执行最后一个命令时,我收到错误

'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`

My node_modules folder is indeed empty and I really have no idea why 'npm install' doesn't add this folder.我的 node_modules 文件夹确实是空的,我真的不知道为什么“npm install”没有添加这个文件夹。 And yes, I googled first before asking this.是的,我在问这个之前先用谷歌搜索。 :) :)

See below my command prompt where I run the following commands:请参阅下面我运行以下命令的命令提示符:

  1. dir (shows my folders of the project root folder, there is no node_modules folder) dir(显示我的项目根文件夹的文件夹,没有node_modules文件夹)
  2. type package.json (fyi, the content of my package.json file)输入 package.json (仅供参考,我的 package.json 文件的内容)
  3. npm install (don't receive any output here..) npm install (这里不接收任何输出..)
  4. npm install -g @angular/cli@1.6.5 npm install -g @angular/cli@1.6.5
  5. npm run test (fyi, it fails) npm 运行测试(仅供参考,它失败了)
  6. dir (fyi, to show you the directories in my folder after the install cmd, there is no node_modules folder) dir(仅供参考,安装cmd后显示我文件夹中的目录,没有node_modules文件夹)

Cmd:命令:

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>

If you have any suggestions, please tell me.如果您有任何建议,请告诉我。

Thanks in advance!提前致谢!

I found the answer myself.我自己找到了答案。

In my project it seems I have a .npmrc file.在我的项目中,我似乎有一个 .npmrc 文件。 This disables the logging of the 'npm install' command.这将禁用“npm install”命令的日志记录。

After temp removing this, I executed npm install and received the following error:在临时删除它后,我执行 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

My issue was that I didn't installed git on my local machine.我的问题是我没有在本地机器上安装 git。 After installing git my npm_install command works fine.安装 git 后,我​​的 npm_install 命令工作正常。

在 package.json 中添加"test": "nodemon --exec \\"mocha -R min\\""

您应该运行npm install -g @angular/cli@1.6.5尝试运行npm install

就我而言,将虚拟内存大小增加到 16gb(在 Windows 上)解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM