标签: node-sass

使用带有npm run-script的node-sass watch选项

所以我在npm包脚本中运行任务,但我想传递watch选项npm start.

这有效:

"scripts": {
  "scss": "node-sass src/style.scss dist/style.css -w"
}
Run Code Online (Sandbox Code Playgroud)

这不会编译,监视或抛出任何错误:

"scripts": {
  "scss": "node-sass src/style.scss dist/style.css",
  "start": "parallelshell \"npm run scss -- -w\""
}
Run Code Online (Sandbox Code Playgroud)

没有parallelshell无论是否有简写都行不通.

我假设问题是运行脚本在引号中传递额外的参数,所以命令如下:

node-sass src/style.scss dist/style.css "-w"
Run Code Online (Sandbox Code Playgroud)

我希望这可以在不添加任何依赖项的情况下工作.我错过了什么?

顺便说一句,我在Windows 10中使用命令提示符/ git bash.

sass build-tools node.js npm node-sass

22
推荐指数
2
解决办法
2万
查看次数

Angular 14 错误:转换失败,出现 1 个错误:错误:未终止的字符串标记

运行 ngserve 时我得到以下结果:

*./src/main.ts - 错误:模块构建失败(来自./node_modules/@ngtools/webpack/src/ivy/index.js)../.component.scss:17:100:错误:未终止的字符串标记

*./src/polyfills.ts` - 错误:模块构建失败(来自./node_modules/@ngtools/webpack/src/ivy/index.js)../.component.scss:17:100:错误:未终止的字符串代币

这个有棱角的版本

    角度 CLI:14.0.6
    节点:16.16.0
    包管理器:NPM 8.14.0
    操作系统:win32 x64
    
    角度:14.0.6
    
    套餐版本
    -------------------------------------------------- --------
    @Angular-devkit/建筑师0.1400.6
    @Angular-devkit/build-Angular 14.0.6
    @Angular-devkit/核心 14.0.6
    @angular-devkit/schematics 14.0.6
    `@角度/cdk 14.0.5`
    @角度/材料14.0.5
    @nguniversal/express-engine 7.1.1
    @schematics/角度14.0.6
    `rxjs 6.6.7`
    打字稿 4.6.4

/.组件.scss

input[type=text]:disabled {
  color: black;
}

.search-row {
  .form-group > label {
    font-size: 1.1em !important;
      color: black;
  }
}

.mat-table {
  th.mat-header-cell {
    font-size: 1.1em !important;
      color: black;
  }
}//<< here line 17.


#block {
  margin: 0% 10%;
}
...
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助

css sass node-sass angular

22
推荐指数
3
解决办法
2万
查看次数

在 Create React App v3.x 中用 Dart-Sass 替换 Node-Sass

有没有人成功地做到了这一点?我目前已node-sass安装在我的 CRA 项目中,我正在尝试替换它,dart-sass但遇到了困难,因为 CRA 错误输出告诉我我需要node-sass安装。有什么方法可以让底层 CRA 配置知道使用我安装的dart-sass包而不是node-sass

在此处输入图片说明

sass node-sass create-react-app

21
推荐指数
2
解决办法
1万
查看次数

找不到模块:错误:无法解析 React 中的“fs”

我想为我的在线编辑器实现一个 SASS 编译器,为此我想使用 npm 包“node-sass”。但是我收到错误

Module not found: Error: Can't resolve 'fs' in '<MyProjectPath>\node_modules\fs.realpath'.
Run Code Online (Sandbox Code Playgroud)

我已经尝试通过以下方式通过 package.json 禁用该模块:

"browser": {
   "fs": false
}
Run Code Online (Sandbox Code Playgroud)

此外,我找到了另一个通过 webpack 配置运行的解决方案,为此,我config-overrides.js使用 npm 包“”在我的根目录中创建了一个包含以下内容的文件“ react-app-rewired”:

module.exports = function override(def_config, env) {
  return {
    ...def_config,
    webpack: (config) => {
      config.resolve = {
        ...config.resolve,
        fallback: {
          "fs": false,
        }
      }
      return config
    },
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,这也不能解决我的错误。有谁知道我该如何修复这个错误?我还希望了解有关如何将 SASS(作为字符串)编译为 CSS(使用 ReactJS)的替代建议。

我当前的package.json:

{
    "name": "client",
    "version": "0.1.0",
    "private": true,
    "proxy": "http://localhost:3001",
    "dependencies": {
        "@codemirror/lang-javascript": "^0.19.3",
        "@testing-library/jest-dom": "^5.16.1",
        "@testing-library/react": …
Run Code Online (Sandbox Code Playgroud)

fs reactjs node-sass

21
推荐指数
2
解决办法
8万
查看次数

要导入 Sass 文件,首先需要安装 node-sass

运行 create-react-app,我在 create-react-app 应用程序中收到错误消息:

要导入 Sass 文件,首先需要安装 node-sass。运行npm install node-sassyarn add node-sass在您的工作区内。

我确实安装了 node-sass。

包.json:

  "devDependencies": {
    "node-sass": "^4.13.0"
  }
Run Code Online (Sandbox Code Playgroud)

项目 node_modules 文件夹:

在此处输入图片说明

我已经卸载、重新安装、更新、清理缓存等。我该如何解决?

sass node.js node-sass create-react-app

18
推荐指数
3
解决办法
1万
查看次数

npm with node-sass和autoprefixer

我使用node-sass将我的所有Sass文件编译为master.css.这很好但现在我想添加前缀.我想只使用npm,没有Gulp或Grunt.

这是我的package.json文件:

{
  "name": "xxxxxx.com",
  "version": "1.0.0",
  "description": "",
  "watches": {
    "sass": "src/scss/**"
  },
  "scripts": {
    "sass": "node-sass src/scss/master.scss -o dist/css/ --style compressed",
    "prefix": "postcss --use autoprefixer dist/css/master.css -d dist/css/master.css",
    "dev": "rerun-script"
  },
  "author": "Jan",
  "license": "ISC",
  "devDependencies": {
    "autoprefixer": "^6.3.1",
    "browserify": "^13.0.0",
    "clean-css": "^3.4.9",
    "node-sass": "^3.4.2",
    "postcss-cli": "^2.5.0",
    "rerun-script": "^0.6.0",
    "uglifyjs": "^2.4.10"
  }
}
Run Code Online (Sandbox Code Playgroud)

我不能让它运行.我使用autoprefixer和postcss-cli.这些模块已在本地安装在项目目录中.我认为我的"剧本"部分是错误的.那看起来怎么样?

compilation node.js npm node-sass autoprefixer

17
推荐指数
2
解决办法
1万
查看次数

是否可以使用Nexus代理单个文件?

我正在尝试通过Nexus 代理node-sass和其他npm库,但是当node-sass的安装后步骤尝试提取文件时遇到问题https://github.com/sass/node-sass/releases/从github 下载/ v3.10.1/linux-x64-48_binding.node.我是公司防火墙的后面,所以我唯一的选择就是让Nexus代理我需要的所有文件.

是否有可能以某种方式将此单个文件添加到Nexus,以便它能够代理并在发送请求时将其发送到https://github.com/sass/node-sass/releases/download/v3.10.1 /linux-x64-48_binding.node

github nexus node-sass

16
推荐指数
1
解决办法
783
查看次数

节点错误:resolve-url-loader:CSS 错误

我试图在我的表面上运行一个 React 项目作为开发服务器,如果给我下面和标题中显示的错误。当我在我的电脑上运行相同的配置时,我没有遇到这个问题。(我尝试创建相同的条件,但它不起作用)。

错误:

./src/assets/scss/black-dashboard-pro-react.scss?v=1.0.0 (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/lib/loader.js??ref--6-oneOf-5-4!./src/assets/scss/black-dashboard-pro-react.scss?v=1.0.0)
Error: resolve-url-loader: CSS error
  source-map information is not available at url() declaration (found orphan CR, try removeCR option)
Run Code Online (Sandbox Code Playgroud)

来自浏览器控制台的完整错误:(Chrome)

Fetch API cannot load file:///C:/Users/Max-T/Documents/Sources/StaffMangerV2/Oauth2Manager-Web/src/assets/scss/black-dashboard-pro-react.scss. URL scheme must be "http" or "https" for CORS request.
(anonymous) @ index.js:1679
s @ index.js:499
(anonymous) @ index.js:479
e.<computed> @ index.js:536
S @ index.js:1517
i @ index.js:1534
(anonymous) @ index.js:1541
(anonymous) @ index.js:1530
(anonymous) @ index.js:1699
(anonymous) @ index.js:1673
s @ index.js:499
(anonymous) @ index.js:479
e.<computed> @ index.js:536
S …
Run Code Online (Sandbox Code Playgroud)

node.js npm reactjs node-sass resolve-url-loader

16
推荐指数
2
解决办法
2万
查看次数

NPM node-sass 安装失败

我正在尝试在一个项目中安装 node-sass,该项目在我的电脑上完美构建和运行,但在我的表面上,我在尝试安装软件包时遇到了重大问题。

注意:我已经多次尝试重新安装和重建项目。

错误总结:

gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Max-T\\Documents\\Sources\\StaffMangerV2\\black-dashboard-pro-react-v1.0.0\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Max-T\Documents\Sources\StaffMangerV2\black-dashboard-pro-react-v1.0.0\node_modules\node-sass
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: …
Run Code Online (Sandbox Code Playgroud)

node.js npm reactjs node-sass npm-install

15
推荐指数
4
解决办法
2万
查看次数

安装node-sass时出现错误

当我安装node-sassReact 项目时,出现以下错误。我尝试了很多东西,但没有一个起作用。我尝试删除它并再次安装它,我尝试启动一个新项目,但它仍然无法正常工作。我将所有内容更新为最新版本:node.js 更新为v16.14.0,npm 更新为v8.3.1

npm ERR! code 1
npm ERR! path C:\Users\XXXXX\Documents\GitHub\XXXXX\Frontend\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\XXXXX\Documents\GitHub\XXXXX\Frontend\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\XXXXX\\Documents\\GitHub\\XXXXX\\Frontend\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm …
Run Code Online (Sandbox Code Playgroud)

sass node.js npm reactjs node-sass

15
推荐指数
3
解决办法
3万
查看次数