node.js 没有找到 gulpfile

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38937095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:29:44  来源:igfitidea点击:

No gulpfile found

node.jsgulplaravel-5.2

提问by Tasmin

I am new in laravel. I am trying the command nmp install. it does not work. Then as shown in their official documentation, I tried

我是laravel的新手。我正在尝试命令 nmp install。这是行不通的。然后如他们的官方文档所示,我尝试了

npm install --global gulp-cli

but I was getting access denied error. So I gave

但我收到拒绝访问错误。所以我给了

sudo npm install --global gulp-cli

It seemed to give me some correct result. then I gave

它似乎给了我一些正确的结果。然后我给了

npm install --no-bin-links

but it says that,

但它说,

"npm WARN [email protected] No description npm WARN [email protected] No repository field."I tried

"npm WARN [email protected] No description npm WARN [email protected] No repository field."我试过

npm install -d

though the result ended with "ok" (after running the command the first line said "it worked if it ends with ok"), it still contains ""npm WARN [email protected] No description npm WARN [email protected] No repository field."And when I gave the command

虽然结果以“ok”结尾(在运行命令后第一行说“如果以ok结尾,它会工作”),但它仍然包含 ""npm WARN [email protected] No description npm WARN [email protected] No repository field."当我发出命令时

gulp

the answer was no gulpfile found. In my project there is a gulpfile.js file (I am not sure about which gulpfile it is talking :\ )

答案是没有找到 gulpfile。在我的项目中有一个 gulpfile.js 文件(我不确定它在谈论哪个 gulpfile :\)

what to do? My node version is V5.12.0

该怎么办?我的节点版本是V5.12.0

回答by Hyder B.

In my case, in order to solve the error, 'no gulpfile found' I wrongly called the configuration file as gulp.jsinstead of gulpfile.js.

在我的情况下,为了解决这个错误,“没有发现gulpfile”我错误地称为配置文件gulp.js来代替gulpfile.js

So just make sure you didn't misspell the file.

所以只要确保你没有拼错文件。

Another possible reason why you might get this error is when you are running the gulp command in the wrong directory. Make sure the gulpfile.js is not inside another folder but within the project folder.

出现此错误的另一个可能原因是当您在错误的目录中运行 gulp 命令时。确保 gulpfile.js 不在另一个文件夹中,而是在项目文件夹中。

回答by user3828102

This error means that gulp doesn't find gulpfile.js to follow the instructions. To solve this error we need to add gulpfile.js to our directory root by running the command.

这个错误意味着 gulp 没有找到 gulpfile.js 来按照说明进行操作。为了解决这个错误,我们需要通过运行命令将 gulpfile.js 添加到我们的根目录中。

Create gulpfile.js and then add

创建 gulpfile.js 然后添加

var gulp = require('gulp');
gulp.task('default', function () { 
    console.log('Hello Gulp!') 
});

回答by Ginger Squirrel

I also had this issue. I created the gulpfile.jsfile through explorer so it was incorrectly named gulpfile.js.txtwhich prevented the gulp command finding it. This only became obvious when I opened the project in a text editor and I saw the extension.

我也有这个问题。我gulpfile.js通过资源管理器创建了该文件,因此它的命名不正确gulpfile.js.txt,从而阻止了 gulp 命令找到它。当我在文本编辑器中打开项目并看到扩展时,这才变得明显。

回答by asabasov

Thanks for creating this issue, I also had it. The fix for me was to put gulpfile.js in the root directory.

感谢您创建此问题,我也遇到了。我的解决方法是将gulpfile.js 放在根目录中

回答by Aaronster

After running 'yo' to create your new project, use 'cd' command to jump to the the root directory of your new project, then you can run 'gulp' commands.

运行“yo”创建新项目后,使用“cd”命令跳转到新项目的根目录,然后运行“gulp”命令。

回答by Super Jade

My gulpFile.jswas not in my root directory as expected!

我的gulpFile.js不在我的根目录中!

I had to find the file, change to that directory, and then run gulp forever --react. (I have a React project.)

我必须找到该文件,切换到该目录,然后运行gulp forever --react. (我有一个 React 项目。)

回答by shaza

I encountered same problem in Laravel 6. I solved it by steps:

我在 Laravel 6 中遇到了同样的问题。我是通过步骤解决的:

npm init
npm install --save-dev gulp
npx mkdirp yourProjectName
npm install --save-dev gulp

Create a gulpfile:Using your text editor, create a file named gulpfile.js in your project root with these contents:

创建 gulpfile:使用文本编辑器,在项目根目录中创建一个名为 gulpfile.js 的文件,其中包含以下内容:

function defaultTask(cb) {
  // place code for your default task here
  cb();
}

exports.default = defaultTask

Full Resource here: https://gulpjs.com/docs/en/getting-started/quick-start

完整资源在这里:https: //gulpjs.com/docs/en/getting-started/quick-start

Hope this helps ypu

希望这对你有帮助

回答by LAdams87

It won't find the gulp file if it is spelled Gulpfile.js, either. That capital G has thrown me down a well or two. Really make sure of your syntax!

如果拼写为 Gulpfile.js,它也不会找到 gulp 文件。那个大写的 G 把我扔了一两口井。真的要确保你的语法!