首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Node-sass未编译

Node-sass未编译
EN

Stack Overflow用户
提问于 2020-08-20 22:06:57
回答 1查看 2.2K关注 0票数 2

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

代码语言:javascript
运行
复制
 {
  "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运行scss时,我看到了这个错误:

代码语言:javascript
运行
复制
> 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

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

EN

回答 1

Stack Overflow用户

发布于 2020-10-25 11:16:59

您使用的是带有全名的watch选项,它需要两个破折号:

代码语言:javascript
运行
复制
node-sass scss --watch -o css

否则,请使用1个短划线和速记w名称:

代码语言:javascript
运行
复制
node-sass scss -w -o css

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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63506881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档