gpt4 book ai didi

sass - 节点sass不编译

转载 作者:行者123 更新时间:2023-12-04 09:03:39 27 4
gpt4 key购买 nike

尝试使用 node-sass 从 scss 生成 css 文件。我的 package.json:

 {
"name": "hello-webpack",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"scss": "node-sass -watch scss -o css"
},
"author": "",
"license": "ISC",
"devDependencies": {
"sass": "^1.26.10",
"sass-loader": "^9.0.3",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.11"
},
"dependencies": {
"node-sass": "^4.14.1"
}
}

但是当我尝试 npm run scss 时,我看到了这个错误:

> node-sass -watch scss -o css

internal/validators.js:120
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:120:11)
at Object.extname (path.js:1229:5)
at getOptions (/Users/mac/Documents/Website/node_modules/node-sass/bin/node-sass:192:40)
at Object.<anonymous> (/Users/mac/Documents/Website/node_modules/node-sass/bin/node-sass:376:15)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-webpack@1.0.0 scss: `node-sass -watch scss -o css`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-webpack@1.0.0 scss script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2020-08-20T14_02_52_371Z-debug.log

路径有什么问题?没错,我有目录 scss 和 css,并且在这两个目录中都有一些文件。

最佳答案

您使用的是全名的 watch 选项,需要 2 个破折号:

node-sass scss --watch -o css

否则使用 1 个破折号和简写 w 名称:

node-sass scss -w -o css

https://www.npmjs.com/package/node-sass#command-line-interface

关于sass - 节点sass不编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63506881/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com