node-sass安装报错解决
报错信息:
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python F:\python\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: F:\python\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (node:child_process:402:12)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at maybeClose (node:internal/child_process:1100:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\code\\lvgl_hello\\code\\Slice\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\code\Slice\node_modules\node-sass
gyp ERR! node -v v16.20.
解决办法
1. yarn install
此时会报以上异常
2. yarn add node-sass@yarn:dart-sass -D
或者:npm install node-sass@npm:dart-sass -D
需要重新安装node-sass,替换成dart-sass:
3. npm run serve
运行项目
完美解决了,不需要重新安装python环境,希望对应有用!