我在6个月前创建了一个wordpress主题模板,并且已经开始工作了,但是由于某些原因,在复制/粘贴并建立了一个新的项目后,我似乎无法让grunt任务运行器工作并编译scss。HTML确实在本地主机上更新,但scss没有编译,然后当 grunt
在终端运行时,我收到以下内容。
PS C:\xampp\htdocs\alwayscircular\wp-content\themes\Seahorse> grunt
grunt : The term 'grunt' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ grunt
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (grunt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Npm审计报告 -- 我运行了npm audit fix -- force -- 但它似乎没有解决这2个漏洞,但我认为它们并不相关
# npm audit report
trim-newlines <3.0.1
Severity: high
Regular Expression Denial of Service in trim-newlines - https://github.com/advisories/GHSA-7p7h-4mm5-852v
fix available via `npm audit fix`
node_modules/trim-newlines
meow 3.4.0 - 5.0.0
Depends on vulnerable versions of trim-newlines
node_modules/meow
2 high severity vulnerabilities
我的Gruntfile.js:
module.exports = function(grunt) {
const sass = require('node-sass');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
css: {
files: ['assets/scss/*.scss', 'assets/scss/**/*.scss'],
tasks: ['css'],
options: {
interrupt: true
}
},
js: {
files: ['js-src/vendor/**/*.js', 'js-src/**/*.js', 'js-src/*.js'],
tasks: ['js'],
options: {
interrupt: true
}
}
},
postcss: {
options: {
map: false,
processors: [
require('autoprefixer')({Browserslist: 'last 10 versions'})
]
},
dist: {
src: 'assets/css/*.css'
}
},
sass: {
options: {
implementation: sass,
outputStyle: 'compressed',
sourceMap: false
},
dist: {
files: {
'assets/css/main.min.css': 'assets/scss/main.scss'
}
}
},
// concat: {
// options: {
// separator: ';'
// },
// all: {
// src: [
// 'js-src/polyfill/*.js',
// 'js-src/lib/*.js',
// 'js-src/_utils.js',
// 'js-src/*.js',
// '!js-src/App.js',
// 'js-src/App.js'
// ],
// dest: 'js/scripts.js'
// }
// },
// uglify: {
// all: {
// files: {
// 'js/scripts.min.js': ['js/scripts.js']
// }
// }
// }
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify-es');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-sass');
grunt.registerTask('css', ['sass', 'postcss']);
grunt.registerTask('js', ['concat', 'uglify']);
grunt.registerTask('default', ['watch']);
};
package.json
{
"name": "Seahorse",
"版本": "2.0.0",
"描述": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\"&& exit 1"
},
"关键词": [],
"作者": "",
"许可证": "ISC",
"devDependencies": {
"grunt": "^1.4.1",
"grunt-postcss": "^0.9.0"
},
"依赖性"。{
"autoprefixer": "^10.2.5",
"grunt-contrib-cat": "^1.0.1",
"grunt-contrib-uglify-es": "^3.3.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-sass": "^3.1.0",
"load-grunt-tasks": "^5.1.0",
"node": "^16.11.1",
"postcss": "^8.2.9"
}
}
任何帮助都将是巨大的,我被卡住了!
你可能缺少grunt-cli。 https://gruntjs.com/getting-started#installing-the-cli