【问题标题】:Error Local Npm module "jshint-stylish" not found when it exists locally (via symlink)本地存在时未找到错误本地 Npm 模块“jshint-stylish”(通过符号链接)
【发布时间】:2014-07-31 08:14:53
【问题描述】:

我的文件夹中有一个 linux 符号链接到一个名为 node_modules 的文件夹,其中包含 grunt 文件,但是当我运行 grunt 时,我得到了这个:

未找到本地 Npm 模块“jshint-stylish”。安装了吗?

我所有其他的 npm 模块都可以正常工作,有什么想法吗?

我的咕噜声文件:

module.exports = function (grunt) {
  grunt.loadNpmTasks('grunt-shell');
  grunt.loadNpmTasks('grunt-open');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-closure-compiler');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('jshint-stylish');

权限:

me@pc:~/dev/root/node_modules$ ls -l
total 96

..
drwxr-xr-x 3 me me 4096 Jun 10 14:57 grunt-shell
drwxr-xr-x 3 me me 4096 Jun 10 15:00 jshint-stylish

..

编辑_____________________ 我作为记者在咕噜声中使用它:

  jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish')
      },
      all: [

【问题讨论】:

  • 我猜你已经检查过了,但你确定 jshint-stylish 模块真的安装了吗?它肯定在那个node_modules 目录中吗?和其他模块权限一样吗?
  • @JamesAllardice 是的,有相同的烫发,请参阅编辑谢谢
  • 看起来您使用 jshint-stylish 的方式不正确……它不是 Grunt 插件。请参阅readme
  • @JamesAllardice 我在 grunt 作为记者使用它,请参阅编辑:)
  • 在您的原始代码中(问题仍然存在)您有grunt.loadNpmTasks('jshint-stylish');。你需要摆脱它。

标签: jshint grunt-contrib-jshint


【解决方案1】:

尝试手动安装模块。

npm install jshint-stylish

为我工作。

【讨论】:

    【解决方案2】:

    load-grunt-configs 所有者 creynders 提示 here 错误
    “未找到本地 Npm 模块 'jshint-stylish'。是否已安装?”
    显然是由 jshint.js 配置文件中对 jshint-stylish 的要求引起的。
    它找不到 jshint-stylish 模块,因为它位于项目外部的目录中。

    但是我无法让他的建议对我有用,但我找到了自己的方式:

    // gruntfile.js
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        config: grunt.file.readJSON('grunt-config.json'),
        jshint_reporter: require('jshint-stylish')
    });
    
    // grunt-config.json
    {
        "jsHintFiles" : [
            "**/modules/*.js"
        ]
    }
    
    // jshint.js
    module.exports = function(grunt) {
        "use strict";
    
        grunt.config.merge({"jshint": {
            "default": {
                options: {
                    reporter: "<%= jshint_reporter %>"
                },
                src: ["<%= config.jsHintFiles %>"]
            }
        }});
    };
    

    【讨论】:

      【解决方案3】:

      检查您的 NODE_PATH 环境变量是否引用了您的 node_modules 目录。
      在本地它将是:

      导出 NODE_PATH=./node_modules

      【讨论】:

        猜你喜欢
        • 2019-01-09
        • 2016-01-17
        • 1970-01-01
        • 2016-10-23
        • 2018-10-05
        • 1970-01-01
        • 2018-07-05
        • 2016-02-16
        • 1970-01-01
        相关资源
        最近更新 更多