Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js grunt安装有问题_Node.js_Gruntjs - Fatal编程技术网

Node.js grunt安装有问题

Node.js grunt安装有问题,node.js,gruntjs,Node.js,Gruntjs,我在上一节课上阅读了文档。执行sudonpm安装-g grunt cli之后,我得到了这个输出 npm http GET https://registry.npmjs.org/grunt-cli npm http 304 https://registry.npmjs.org/grunt-cli npm http GET https://registry.npmjs.org/findup-sync npm http GET https://registry.npmj

我在上一节课上阅读了文档。执行
sudonpm安装-g grunt cli之后,我得到了这个输出

    npm http GET https://registry.npmjs.org/grunt-cli
    npm http 304 https://registry.npmjs.org/grunt-cli
    npm http GET https://registry.npmjs.org/findup-sync
    npm http GET https://registry.npmjs.org/nopt
    npm http GET https://registry.npmjs.org/resolve
    npm http 304 https://registry.npmjs.org/resolve
    npm http 304 https://registry.npmjs.org/findup-sync
    npm http 304 https://registry.npmjs.org/nopt
    npm http GET https://registry.npmjs.org/abbrev
    npm http GET https://registry.npmjs.org/glob
    npm http GET https://registry.npmjs.org/lodash
    npm http 304 https://registry.npmjs.org/abbrev
    npm http 304 https://registry.npmjs.org/glob
    npm http 304 https://registry.npmjs.org/lodash
    npm http GET https://registry.npmjs.org/graceful-fs
    npm http GET https://registry.npmjs.org/inherits
    npm http GET https://registry.npmjs.org/minimatch
    npm http 304 https://registry.npmjs.org/minimatch
    npm http 304 https://registry.npmjs.org/inherits
    npm http 304 https://registry.npmjs.org/graceful-fs
    npm http GET https://registry.npmjs.org/lru-cache
    npm http GET https://registry.npmjs.org/sigmund
    npm http 304 https://registry.npmjs.org/sigmund
    npm http 304 https://registry.npmjs.org/lru-cache
    npm http GET https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz
    npm http 200 https://registry.npmjs.org/sigmund/-/sigmund-1.0.0.tgz
    /usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
    grunt-cli@0.1.11 /usr/local/lib/node_modules/grunt-cli
    ├── resolve@0.3.1
    ├── nopt@1.0.10 (abbrev@1.0.4)
    └── findup-sync@0.1.2 (lodash@1.0.1, glob@3.1.21)
在此之后,当我发出
grunt
时,我收到了这个消息

    grunt-cli: The grunt command line interface. (v0.1.11)

    Fatal error: Unable to find local grunt.

    If you're seeing this message, either a Gruntfile wasn't found or grunt
    hasn't been installed locally to your project. For more information about
    installing and configuring grunt, please see the Getting Started guide:

    http://gruntjs.com/getting-started
在这之后,我也按照解决我的问题,但我仍然得到同样的错误上面

更新

Grunfile.js

    module.exports = function () {
        grunt.initConfig({
            min: {
                dist: {
                    src: 'file-one.js',
                    dest: 'file-one.min.js'
                }
            }
        });
    }
package.json文件

    {
      "name": "grunt",
      "version": "0.1.0",
      "devDependencies": {
        "grunt": "~0.1.11",
        "grunt-contrib-jshint": "~0.6.3",
        "grunt-contrib-nodeunit": "~0.2.0",
        "grunt-contrib-uglify": "~0.2.2"
      }
    }

您已经将
grunt cli
作为一个全局软件包安装,但还需要在本地安装
grunt
grunt cli
软件包安装一个全局命令行工具,但该命令行工具只是尝试加载本地安装
grunt
模块。这样做是为了允许人们为不同的项目安装多个版本的grunt,您需要将grunt本身作为本地包安装在您正在处理的项目中

从您链接到的页面:

请注意,安装grunt cli不会安装grunt任务运行程序!Grunt CLI的工作很简单:运行安装在Gruntfile旁边的Grunt版本。这允许在同一台机器上同时安装多个版本的Grunt


因此,您需要在package.json文件中将
grunt
作为本地依赖项,就像任何其他模块一样,您不会在其中列出
grunt cli

您已经将
grunt cli
作为一个全局包安装,但您还需要在本地安装
grunt
grunt cli
软件包安装一个全局命令行工具,但该命令行工具只是尝试加载本地安装
grunt
模块。这样做是为了允许人们为不同的项目安装多个版本的grunt,您需要将grunt本身作为本地包安装在您正在处理的项目中

从您链接到的页面:

请注意,安装grunt cli不会安装grunt任务运行程序!Grunt CLI的工作很简单:运行安装在Gruntfile旁边的Grunt版本。这允许在同一台机器上同时安装多个版本的Grunt


因此,您需要在package.json文件中将
grunt
作为本地依赖项,就像任何其他模块一样,您不会在其中列出
grunt cli

npm update
对我有用。Grunt必须更新。

npm更新
对我有用。Grunt必须更新。

您有Gruntfile和package.json吗?您有Gruntfile和package.json吗?我的项目中有package.json和Gruntfile.js文件。请查看我更新的问题。但是您是否实际安装了
grunt
,或者只是在您的package.json中列出了它?尝试运行npm安装或专门运行npm安装grunt@0.1.11I已经安装了npm并安装了grunt。但是现在我得到这个错误
警告:找不到任务“min”。使用--force继续。由于警告而中止。
当我运行
grunt min
命令时。@2619您有
min
的配置,并且正在尝试运行它,但是从您显示的情况来看,没有这样的任务。如果您试图运行
uglify
,您需要命名任务并进行配置。您能告诉我如何在上面的示例中配置min task吗?我的项目中有package.json和Gruntfile.js文件。请查看我更新的问题。但是您是否实际安装了
grunt
,或者只是在您的package.json中列出了它?尝试运行npm安装或专门运行npm安装grunt@0.1.11I已经安装了npm并安装了grunt。但是现在我得到这个错误
警告:找不到任务“min”。使用--force继续。由于警告而中止。
当我运行
grunt min
命令时。@2619您有
min
的配置,并且正在尝试运行它,但是从您显示的情况来看,没有这样的任务。如果您试图运行
uglify
,则需要命名任务并对其进行配置。在上面的示例中,您能告诉我如何配置min task吗?