为WordPress Understrap主题安装依赖项时出现node-sass错误

时间:2019-11-10 21:36:10

标签: node-sass

我已经将Understrap主题用于WordPress已有一段时间了,但是没有问题,但是今天我在运行命令node-sass安装主题的时候遇到了yarn install错误。依赖性。

我已阅读到 node-sass 的最新版本在尝试安装时出现错误,因此我尝试使用命令yarn add node-sass@4.13进行安装,但这不起作用因为Understrap主题中的一个软件包与最新版本的 node-sass 捆绑在一起,所以会导致此错误。这是我得到的完整错误日志:

error C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\gulp-sass\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\gulp-sass\node_modules\node-sass
Output:
Building: C:\Program Files\nodejs\node.exe C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@12.13.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21) {
gyp verb `which` failed   stack: 'Error: not found: python2\n' +
gyp verb `which` failed     '    at getNotFoundError (C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:13:12)\n' +
gyp verb `which` failed     '    at F (C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:68:19)\n' +
gyp verb `which` failed     '    at E (C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:80:29)\n' +
gyp verb `which` failed     '    at C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:89:16\n' +
gyp verb `which` failed     '    at C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\isexe\\index.js:42:5\n' +
gyp verb `which` failed     '    at C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\isexe\\windows.js:36:5\n' +
gyp verb `which` failed     '    at FSReqCallback.oncomplete (fs.js:158:21)',
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\gulp-sass\node_modules\node-sass
gyp ERR! node -v v12.13.0




PS C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child> yarn install node-sass@4.13
yarn install v1.13.0
error `install` has been replaced with `add` to add new dependencies. Run "yarn add node-sass@4.13" instead.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
PS C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child> yarn install node-sass@4.13
yarn install v1.13.0
error `install` has been replaced with `add` to add new dependencies. Run "yarn add node-sass@4.13" instead.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
PS C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child> yarn add node-sass@4.13
yarn add v1.13.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.7: The platform "win32" is incompatible with this module.
info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > bootstrap@4.3.1" has unmet peer dependency "jquery@1.9.1 - 3".
[4/4] Building fresh packages...
[-/6] ⠠ waiting...
[-/6] ⠠ waiting...
[-/6] ⠠ waiting...
[4/6] ⠠ node-sass
error C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\gulp-sass\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\gulp-sass\node_modules\node-sass
Output:
Building: C:\Program Files\nodejs\node.exe C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@12.13.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:158:21) {
gyp verb `which` failed   stack: 'Error: not found: python2\n' +
gyp verb `which` failed     '    at getNotFoundError (C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:13:12)\n' +
gyp verb `which` failed     '    at F (C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:68:19)\n' +
gyp verb `which` failed     '    at E (C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:80:29)\n' +
gyp verb `which` failed     '    at C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\which\\which.js:89:16\n' +
gyp verb `which` failed     '    at C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\isexe\\index.js:42:5\n' +
gyp verb `which` failed     '    at C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\isexe\\windows.js:36:5\n' +
gyp verb `which` failed     '    at FSReqCallback.oncomplete (fs.js:158:21)',
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Ben\AppData\Local\Programs\Python\Python37-32\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 (child_process.js:295:12)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\xampp\\htdocs\\pug_test\\wp-content\\themes\\understrap-child\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cs_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\xampp\htdocs\pug_test\wp-content\themes\understrap-child\node_modules\gulp-sass\node_modules\node-sass
gyp ERR! node -v v12.13.0

还有其他人使用此WordPress主题吗?如果是这样,您是否知道如何编辑package.json以解决node-sass的问题?非常感谢。

1 个答案:

答案 0 :(得分:0)

我在Understrap中遇到了类似的问题。我在纱线上使用npm。

我设法通过抓住最新版本的node-sass来解决问题,而不是尝试使用较旧版本的understrap。

对我来说,解决方法是运行npm i node-sass,但我知道这对您不起作用。

无论如何,您是否只能获得yarn来获取最新版本的node-sass而不是指定版本?