我有一个linux符号链接,指向grunt文件所在文件夹中的node_modules文件夹,但当我运行grunt时,我得到的结果是:
找不到本地Npm模块"jshint-stylish“。安装好了吗?
我的所有其他npm模块都工作得很好,有什么想法吗?
我的grunt文件:
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
..EDIT_____________________我以记者的身份使用它:
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [发布于 2015-12-11 05:04:03
尝试手动安装模块。
npm install jshint-stylish对我很管用。
发布于 2016-11-08 02:44:00
load-grunt configs owner 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 %>"]
}
}});
};发布于 2019-07-17 00:29:12
检查您的NODE_PATH环境变量是否引用了您的node_modules目录。
在本地它将是:
导出节点路径=./节点模块
https://stackoverflow.com/questions/24143154
复制相似问题