我使用#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char ch = 0;
int state = 0;
char buff[128];
char ops = 0;
unsigned int result = 0;
int i = 0, idx = 0;
char expr[1024];
int cnt = 0;
if (scanf("%[^=]=%n", expr, &cnt) <= 0)
return 0;
while(idx < cnt) {
ch = expr[idx++];
printf("state %d ch %c\n", state, ch);
switch(state) {
case 0:
if ((ch <= '9') && (ch >= '0')) {
state++;
buff[i++] = ch;
}
break;
case 1:
if ((ch <= '9') && (ch >= '0')) {
buff[i++] = ch;
} else {
buff[i] = '\0';
if (i > 0) {
unsigned int num = atoi(buff);
switch (ops) {
case '-':
result -= num;
break;
case '+':
result += num;
break;
case '*':
result *= num;
break;
case '/':
result /= num;
break;
default:
result = num;
break;
}
printf("> found fact %d, result %u\n", num, result);
}
i = 0;
if ((ch == '-') || (ch == '+') || (ch == '*') || (ch == '/')) {
state = 0;
ops = ch;
printf("> found ops %c\n", ch);
} else if ((ch == ' ') || (ch == '\t')) {
continue;
} else if (ch == '=') {
break;
} else {
// expression end
break;
}
}
break;
default:
break;
}
}
printf("> result '%u' ", result);
return 0;
}
作为构建工具。我的npm
文件中有以下行。
package.json
当我运行"scripts": {
"css": "node-sass --include ./node_module --include-scss --compress ./src/css/main.scss ./dist/css/style.css",
}
时,它显示在终端
npm run css
但是当我检查> website@1.0.0 css /Projects/Lab/website
> node-sass --include ./node_module --include-scss --compress ./src/css/main.scss ./dist/css/style.css
文件时,它是空的。
为什么以及如何解决此问题?
更新
现在我收到了错误
./dist/css/style.css
在我的/Projects/website/node_modules/node-sass/lib/extensions.js:158
throw new Error([
^
Error: The `libsass` binding was not found in /Projects/website/node_modules/node-sass/vendor/darwin-x64-47/binding.node
This usually happens because your node version has changed.
Run `npm rebuild node-sass` to build the binding for your current node version.
at Object.sass.getBinaryPath (/Projects/website/node_modules/node-sass/lib/extensions.js:158:11)
at Object.<anonymous> (/Projects/website/node_modules/node-sass/lib/index.js:16:36)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Projects/website/node_modules/node-sass/lib/render.js:9:12)
at Module._compile (module.js:413:34)
npm ERR! Darwin 13.4.0
npm ERR! argv "/Users/xafar/.nvm/versions/node/v5.5.0/bin/node" "/Users/xafar/.nvm/versions/node/v5.5.0/bin/npm" "run" "css"
npm ERR! node v5.5.0
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! website@1.0.0 css: `node-sass --include-scss ./src/css/main.scss ./dist/css/style.css`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the website@1.0.0 css script 'node-sass --include-scss ./src/css/main.scss ./dist/css/style.css'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the website package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-sass --include-scss ./src/css/main.scss ./dist/css/style.css
npm ERR! You can get their info via:
npm ERR! npm owner ls website
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Projects/website/npm-debug.log
[nodemon] app crashed - waiting for file changes before starting...
文件中更改以下行后。
package.json
我正在关注以下博客,以使其发挥作用。
https://moroccojs.org/tutorials/npm-based-front-end-workflow/ https://medium.com/@brianhan/watch-compile-your-sass-with-npm-9ba2b878415b#.pfupo150c
答案 0 :(得分:1)
2021 年,node-sass 已正式弃用,建议改用 dart sass。
sass 语法改变了,只有新的 dart-sass 支持。
sass-lang.com/blog/libsass-is-depr...
我如何迁移? 如果您是 Node Sass 的用户,迁移到 Dart Sass 很简单:只需将 package.json 文件中的 node-sass 替换为 sass。两个包都公开了相同的 JavaScript API。
答案 1 :(得分:0)