有咕噜声安装问题

 你就是一朵奇葩_518 发布于 2023-02-10 13:59

我按照grunt网站上的文档.执行后sudo npm install -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

在此之后我也按照这个链接来解决我的问题,但我仍然得到上面相同的错误.

UPDATE

Gruntfile.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"
      }
    }

loganfsmyth.. 7

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

从您链接到的页面:

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

所以你需要grunt在package.json文件中作为本地依赖项,就像任何其他模块一样,你不会grunt-cli在那里列出.

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

    从您链接到的页面:

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

    所以你需要grunt在package.json文件中作为本地依赖项,就像任何其他模块一样,你不会grunt-cli在那里列出.

    2023-02-10 14:01 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有