主要错误
gyp verb which failed Error: not found: python2
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! node-sass@4.14.1 postinstall:
node scripts/build.js
全部错误
bash
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 (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\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 (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\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 (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:13:12)\n' +
gyp verb `which` failed ' at F (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:68:19)\n' +
gyp verb `which` failed ' at E (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:80:29)\n' +
gyp verb `which` failed ' at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:89:16\n' +
gyp verb `which` failed ' at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\isexe\\index.js:42:5\n' +
gyp verb `which` failed ' at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\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` failed Error: not found: python
gyp verb `which` failed at getNotFoundError (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:158:21)
gyp verb `which` failed python Error: not found: python
gyp verb `which` failed at getNotFoundError (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\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: python\n' +
gyp verb `which` failed ' at getNotFoundError (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:13:12)\n' +
gyp verb `which` failed ' at F (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:68:19)\n' +
gyp verb `which` failed ' at E (D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:80:29)\n' +
gyp verb `which` failed ' at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\which\\which.js:89:16\n' +
gyp verb `which` failed ' at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\isexe\\index.js:42:5\n' +
gyp verb `which` failed ' at D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\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 could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at callback (D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\graceful-fs\polyfills.js:306:20)
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:158:21)
gyp ERR! System Windows_NT 10.0.22631
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\small software\\developer\\OpenSourceProjects\\book-v2.0\\sq-ui\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\small software\developer\OpenSourceProjects\book-v2.0\sq-ui\node_modules\node-sass
gyp ERR! node -v v12.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\watchpack-chokidar2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN sass-loader@10.1.0 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@10.1.0 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@2.2.1 requires a peer of eslint@>=1.6.0 <7.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 postinstall 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! C:\Users\sy-sqw\AppData\Roaming\npm-cache\_logs\2024-09-15T08_49_59_575Z-debug.log
解决:
node-sass 问题
node-sass版本需与node版本对应,如下
可在项目根目录文件package.json
中查看node-sass
版本,没有请忽略
bash
"devDependencies": {
"node-sass": "4.14.1",
"sass-loader": "10.1.0"
},
设置镜像
bash
// 设置国内npm镜像地址
npm config set registry http://registry.npmmirror.com
// 查询npm配置
npm config list
安装编译环境
bash
npm install -g node-gyp
// 在 Windows 上?想要编译原生 Node 模块吗?使用这一行安装构建工具。以管理员身份启动 PowerShell 并运行
npm install --global --production windows-build-tools
https://www.npmjs.com/package/windows-build-tools
卸载安装失败的包,重新安装
bash
npm uninstall node-sass
npm install sass -i
最后
bash
npm install