node.js - 使用 Yeoman 设置 AngularJS 项目后出现 "npm install"问题

标签 node.js angularjs gruntjs npm yeoman

我的问题出现在使用以下命令创建 Angular 项目之后(甚至期间):

yo angular

在从 package.json(你运行的“npm install”)安装所有 devDependencies 的过程中,我注意到 node_modules 文件夹中缺少一些模块。

因此,之后我使用“npm install name_of_the_module --save-dev”再次下载(因此它们将下载并包含在 package.json 的 devDependencies 选项中)。

但是例如,如果我删除 node_modules 文件夹并执行命令 npm install 它将开始安装但会遗漏一些模块,有时遗漏的模块是与上次运行的 npm install 不同。

我不知道如何面对这个,因为我需要为团队设置项目,他们要做的第一件事就是执行 npm install & bower install(这是最后一个工作正常)。

package.json的内容是:

{
  "name": "angular_test",
  "version": "0.0.0",
  "dependencies": {},
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-autoprefixer": "^0.7.6",
    "grunt-concurrent": "^0.5.0",
    "grunt-contrib-clean": "^0.5.0",
    "grunt-contrib-concat": "^0.4.0",
    "grunt-contrib-connect": "^0.7.1",
    "grunt-contrib-copy": "^0.5.0",
    "grunt-contrib-cssmin": "^0.9.0",
    "grunt-contrib-htmlmin": "^0.3.0",
    "grunt-contrib-imagemin": "^0.8.1",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-contrib-uglify": "^0.4.1",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-filerev": "^0.2.1",
    "grunt-google-cdn": "^0.4.0",
    "grunt-karma": "^0.9.0",
    "grunt-newer": "^0.7.0",
    "grunt-ng-annotate": "^0.3.2",
    "grunt-svgmin": "^0.4.0",
    "grunt-usemin": "^2.4.0",
    "grunt-wiredep": "^1.7.0",
    "imagemin-jpegtran": "^2.0.0",
    "imagemin-pngquant": "^2.0.0",
    "jshint-stylish": "^0.2.0",
    "karma": "^0.12.24",
    "karma-jasmine": "^0.1.5",
    "karma-phantomjs-launcher": "^0.1.4",
    "load-grunt-tasks": "^0.6.0",
    "time-grunt": "^0.3.2"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test"
  }
}

执行 npm install 后得到的错误或日志是:

npm WARN optional dep failed, continuing imagemin-optipng@1.0.0
npm WARN optional dep failed, continuing http-signature@0.10.0
npm WARN optional dep failed, continuing imagemin-jpegtran@1.0.0
npm WARN optional dep failed, continuing imagemin-pngquant@1.0.2
npm WARN optional dep failed, continuing imagemin-gifsicle@1.0.0
npm ERR! EEXIST, open 'C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock'
File exists: C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock
Move it away, and try again.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\myself\Documents\PHPStorm_Workspace\angular_test
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path C:\Users\myself\AppData\Roaming\npm-cache\78af9c6a-m-cache-lodash-2-4-1-package-tgz.lock
npm ERR! code EEXIST
npm ERR! errno 47
npm ERR! not ok code 0

更新

所有这些问题都是因为“npm”而出现的,所以在研究了一下之后,npm 的创建者建议下载最新版本,该版本只能使用...

npm install -g npm@next

npm install -g npm@2.1.2 (in this case is only for the current release 2.1.2, which is the latest release)

当我找到 github 讨论时,我会用它更新帖子。

最佳答案

这是一个错误,可以通过更新您的 npm 版本 (https://github.com/npm/npm/issues/6318) 来修复。 试试:npm -g install npm@next

关于node.js - 使用 Yeoman 设置 AngularJS 项目后出现 "npm install"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26145711/

相关文章:

Node.js 在 Express 框架中使用 setKeepAlive()

javascript - RestAngular:put 和 customPUT 正在发送旧对象,而不是更新对象

javascript - 如何在 .on click 事件中使用 $scope ?

node.js - 警告 : Task "clean:server" not found

coffeescript - 使用 Grunt 连接和缩小 RequireJS

css - 当我运行 grunt 时,我的 css 没有更新

javascript - 将变量从 Jquery 传递到 Node 以运行 git 命令

node.js - Node - GraphQL - Ad.user 字段类型必须是输出类型,但得到 : undefined

node.js - 范围内的 NPM 软件包二进制文件未添加到 PATH

AngularJS promise 在使用 Jasmine 进行测试时不会调用 then