当前位置: 首页 > 知识库问答 >
问题:

VS 2019 Gruntile。使用“sass=require('node-sass')时未找到任何任务

伍昱
2023-03-14

我第一次尝试在一个新的平台上设置grunt sass。Net核心3.1 web应用程序。我已经完成了MSFT将grunt添加到此处概述的项目中的步骤,然后使用grunt sass说明中的步骤对其进行了修改。

但是,这会导致任务运行器资源管理器声明未找到任何任务。这是我的包裹。json:

{
  "name": "chapelstudios_www",
  "version": "0.0.2",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://me@bitbucket.org/me/chapelstudios_www.git"
  },
  "author": "mr",
  "license": "ISC",
  "homepage": "https://bitbucket.org/me/chapelstudios_www#readme",
  "private": true,
  "devDependencies": {
    "grunt": "^1.0.4",
    "grunt-cli": "^1.3.2",
    "grunt-sass": "^3.1.0",
    "node-sass": "^4.13.1"
  },
  "dependencies": {
    "gulp": "^4.0.2"
  }
}

这是我的Gruntile。js:

const sass = require('node-sass');
require('load-grunt-tasks')(grunt);

module.exports = function (grunt) {
    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // Sass
        sass: {
            options: {
                implementation: sass,
                sourceMap: true, // Create source map
                outputStyle: 'compressed' // Minify output
            },
            dist: {
                files: [
                    {
                        expand: true, // Recursive
                        cwd: "Styles", // The startup directory
                        src: ["**/*.scss"], // Source files
                        dest: "wwwroot/css", // Destination
                        ext: ".css" // File extension
                    }
                ]
            }
        }
    });

    // Load the plugin
    grunt.loadNpmTasks('grunt-sass');

    // Default task(s).
    grunt.registerTask('default', ['sass']);
};

我不知道如何获得更详细的错误信息,但我已经跟踪到了

const sass = require('node-sass');

grunt sass指令要求的行。如果我将其更改为旧教程建议的字符串“sass”,则任务将显示,但在我尝试实际运行它时失败。

我还从项目目录中的一个高架PowerShell窗口运行了以下安装,试图确保它们在本地安装到项目中,因为我听说这是一个主要问题:

npm install
npm install grunt
npm install grunt-cli
npm install --save-dev node-sass grunt-sass

在这一点上,我没有想法,但我是个新手,所以我肯定我错过了一些明显的东西。

共有3个答案

应志用
2023-03-14

我发现以下错误,导致我做重建:

Error: Missing binding A:\Projects\Repos\chapelstudios_www\node_modules\node-sass\vendor\win32-x64-79\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 13.x

Found bindings for the following environments:
  - Windows 64-bit with Node.js 10.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
柴坚诚
2023-03-14

恢复一个古老的话题,但这是对我有效的。YMMV。

  • 在Visual Studio中,转到:工具-

我不知道这样做是否有任何副作用。

信用:https://developercommunity.visualstudio.com/solutions/314606/view.html

宁锐
2023-03-14

对于其他使用现有项目访问此的人来说,我在新计算机上的一个预先存在的node-sass/grunt文件中遇到了这个问题,我发现在我的package.json中增加node-sass的版本会导致VS重新安装打包并更新绑定,如另一个答案中所述。

我有点怀疑在我的命令提示符下运行grunt和VS使用的任何东西在版本上是有区别的,因为如果我手动运行grunt文件,它可以正常工作,但不会显示在TaskRunner Explorer中。

 类似资料:
  • 在 v4.3.0之前本项目都是基于node-sass进行构建的,但node-sass底层依赖 libsass,导致很多用户安装的特别的困难,尤其是 windows 用户,它强制用户在windows环境中必须安装python2和Visual Studio才能编译成功。 所以为了解决这个问题,本项目在 v4.3.0修改为dart-sass进行构建,它能在保证性能的前提下大大简化用户的安装成本。通过这个

  • config:macOS High Sierra,version 10.13.2,node:v8.1.2 npm:5.0.3当我在angularjs项目中运行npm start时,我得到以下错误: 在此之后我运行: 现在我得到了这个错误: 为什么npm不安装Node-Sass?如何安装Node-Sass?

  • 问题内容: 我想在应用程序中使用该模块,以从中受益。 我执行了安装模块的操作,到目前为止没有错误。 现在,混乱开始了: 如果我只是在终端中打开进行尝试,那么一切正常,但是如果我将其包含在项目文件中并运行,则会收到以下错误消息: npmjs.com上的模块描述指出,在Ubuntu下解决该问题可能存在问题,以及如何解决此问题,但我的机器上不是这种情况。 我找不到任何有用的信息,因此希望您能对我有所帮助

  • 我对节点的SASS有问题。Mac上的js(OS X El Capitan) 当我尝试使用命令node sass-o css sass/style将一个scss文件编译成css时。scss'我收到以下错误: 节点sass:未找到命令 问题是什么?我如何解决?

  • 问题内容: 配置:macOS High Sierra,版本10.13.2,节点:v8.1.2 npm:5.0.3在我的angularjs项目中运行npm start时,出现以下错误: 之后,我运行: 现在我得到这个错误: 为什么npm不安装node-sass?如何安装node-sass? 问题答案: 解决方法如下: 请享用!

  • 我收到这个错误 未能编译/节点\u模块/primeflex/src/\u变量。scss(./node_modules/css loader/dist/cjs.js??ref--8-oneOf-3-1!。/node_modules/postss loader/src??ref--8-oneOf-3-2!。/node_modules/sass loader/dist/cjs??ref--8-oneOf