[英]Cannot install and run gulp via npm
I am trying to install gulp via npm so that I can run my project. 我试图通过NPM安装吞掉 ,这样我可以运行我的项目。
As far as I can tell, all I need to do is run "npm install gulp" from the command line of my project location like so : 据我所知,我需要做的就是从项目位置的命令行运行“npm install gulp” ,如下所示:
However it doesn't seem to work, because if I run "gulp" from the command line nothing happens. 但它似乎不起作用,因为如果我从命令行运行“gulp”没有任何反应。
In my package.json file I have these dependencies : 在我的package.json文件中,我有这些依赖项:
"devDependencies": {
"autoprefixer-stylus": "^0.7.1",
"browser-sync": "^2.8.2",
"gulp": "^3.9.0",
"gulp-cache": "^0.3.0",
"gulp-concat": "^2.6.0",
"gulp-if": "^1.2.5",
"gulp-imagemin": "^2.3.0",
"gulp-minify-html": "^1.0.4",
"gulp-nunjucks-html": "^1.2.2",
"gulp-order": "^1.1.1",
"gulp-plumber": "^1.0.1",
"gulp-stylus": "^2.0.6",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.6",
"jeet": "^6.1.2",
"kouto-swiss": "^0.11.13",
"minimist": "^1.1.3",
"rupture": "^0.6.1"
},
Is there some kind of conflict happening with my package.json file? 我的package.json文件是否发生了某种冲突?
If I run "npm install grunt" from an empty directory I get this : 如果我从一个空目录运行“npm install grunt”,我得到这个:
Sorry, I'm very new to npm, grunt, gulp etc.. :( 对不起,我是新来的npm,grunt,gulp等.. :(
您还需要全局安装gulp
:
npm -g install gulp
Install globally and make sure it is in your path. 全局安装并确保它在您的路径中。 here is more info -> https://stackoverflow.com/a/24042936/173234
这里有更多信息 - > https://stackoverflow.com/a/24042936/173234
This is a combo of understanding npm
and PATH
settings. 这是理解
npm
和PATH
设置的组合。 When you run npm install gulp
, or npm install
in general, it installs that module inside of the current directory under the node modules directory. 当您运行
npm install gulp
或npm install
时,它会将该模块安装在node modules目录下的当前目录中。 So if you are in C:\\Oliver\\test
and you run npm install gulp
, it will install gulp in C:\\Oliver\\test\\node_modules\\gulp
. 因此,如果你在
C:\\Oliver\\test
并运行npm install gulp
,它将在C:\\Oliver\\test\\node_modules\\gulp
安装C:\\Oliver\\test\\node_modules\\gulp
。 Since the PATH
variable, which is a variable that contains a list of directories to look up executables (like gulp), doesn't specify the C:\\Oliver\\test\\node_modules\\gulp
directory, it will never find the gulp command. 由于
PATH
变量(包含查找可执行文件的目录列表(如gulp)的变量)未指定C:\\Oliver\\test\\node_modules\\gulp
目录,因此它永远不会找到C:\\Oliver\\test\\node_modules\\gulp
命令。 To solve this, you need to use the npm install -g
command where the -g
flag specifies a global install, which means it puts it somewhere that is available in the PATH
(I'm not sure where this is on Windows). 要解决这个问题,你需要使用
npm install -g
命令,其中-g
标志指定全局安装,这意味着它将它放在PATH
可用的位置(我不确定它在Windows上的位置)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.