全局安装package.json依赖关系 [英] Install package.json dependencies globally

查看:734
本文介绍了全局安装package.json依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  {
name: xxx_web_app,
version:1.0.0,
description:,
main:gulpfile.js,
scripts: {
test:echo \错误:未指定测试\&& exit 1
},
repository:{
type :git,
url:some.git
},
author:,
license:ISC,
依赖关系:{
bower:^ 1.4.1,
connect-history-api-fallback:^ 1.1.0,
gulp :^ 3.8.11,
gulp-clean:^ 0.3.1,
gulp-coffee:^ 2.3.1,
gulp-connect :^ 2.2.0,
gulp-jshint:^ 1.10.0,
gulp-minify-css:^ 1.1.1,
gulp-sass:^ 1.3.3,
gulp-slim:^ 0.1.0,
gulp-uglify:^ 1.2.0,
gulp-util:^ 3.0.4,
gulp-webserver:^ 0.9.0
}
}

当我运行' npm i nstall -g '我在控制台中看到我的所有依赖关系都会被安装。但是当我尝试执行时,例如,gulp(' gulp -v ')我得到了:

<$ p $ > code>zsh:command not found:gulp

但是如果我执行' npm install -g gulp '这件事情会很好。那么,我怎样才能从我的package.json全局安装所有依赖项,而无需一次安装?提前致谢!



我的系统是OS X Yosemite。

解决方案

npm install -g npm在包含 package.json 文件的目录中执行时,安装--global 将会将所有软件包安装为全局软件包。

使用 npm ls -g 来检查这些软件包的安装位置。添加上面的命令给你的shell的路径。看起来你正在使用zsh。



这些步骤应该可行:

进入你的主目录并找到这个文件.zshrc并找到与

  export PATH = 

并修改它:

  export PATH =path_to_global_packages:$ PATH

在终端上打开一个新选项卡,以使更改生效并尝试运行 gulp -v



注意:最好的做法是为每个项目在本地安装软件包,而不是全局为机器上的所有项目安装。 b $ b

There is the following 'package.json' file with dependencies:

{
  "name": "xxx_web_app",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "some.git"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bower": "^1.4.1",
    "connect-history-api-fallback": "^1.1.0",
    "gulp": "^3.8.11",
    "gulp-clean": "^0.3.1",
    "gulp-coffee": "^2.3.1",
    "gulp-connect": "^2.2.0",
    "gulp-jshint": "^1.10.0",
    "gulp-minify-css": "^1.1.1",
    "gulp-sass": "^1.3.3",
    "gulp-slim": "^0.1.0",
    "gulp-uglify": "^1.2.0",
    "gulp-util": "^3.0.4",
    "gulp-webserver": "^0.9.0"
  }
}

When I run 'npm install -g' I see in console that all my dependencies will be installed. But when I try to execute, for example, gulp ('gulp -v') I got:

"zsh: command not found: gulp"

But if I execute 'npm install -g gulp' the thing will work good. So, how can I install all dependencies from my package.json globally without installing one after one? Thanks in advance!

My system is OS X Yosemite.

解决方案

npm install -g or npm install --global when executed within a directory that contains the package.json file will install all the packages as a global package.

Use npm ls -g to check exactly where these packages are installed. Add the path that the above command gives to your appropriate shell. Looks like you are using a zsh.

These steps should work:

cd into your home directory and find this file .zshrc and look for the line with

export PATH=

and modify it like:

export PATH="path_to_global_packages:$PATH"

Open a new tab on your terminal for the changes to take effect and try running gulp -v

Note: One best practice is to install packages locally for each project rather than globally for all projects on a machine.

这篇关于全局安装package.json依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆