报错完整信息如下:

error D:\xxx\xxx\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: D:\xxx\xxx\node_modules\node-sass
Output:
Binary found at D:\software\nodesass\win32-x64-72_binding.node
Testing binary
Binary has a problem: Error: The module '\\?\D:\software\nodesass\win32-x64-72_binding.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 72. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:717:18)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at module.exports (D:\xxx\xxx\node_modules\node-sass\lib\binding.js:19:10)
    at Object.<anonymous> (D:\xxx\xxx\node_modules\node-sass\lib\index.js:14:35)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
Building the binary locally
Building: C:\Program Files\nodejs\node.exe D:\xxx\xxx\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 [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'D:\\xxx\\xxx\\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 info using node-gyp@3.8.0
gyp info using node@10.14.1 | 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 (D:\xxx\xxx\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\xxx\xxx\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\xxx\xxx\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\xxx\xxx\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (D:\xxx\xxx\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\xxx\xxx\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\xxx\xxx\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\xxx\xxx\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python2\n    at getNotFoundError (D:\\xxx\\xxx\\node_modules\\which\\which.js:13:12)\n    at F (D:\\xxx\\xxx\\node_modules\\which\\which.js:68:19)\n    at E (D:\\xxx\\xxx\\node_modules\\which\\which.js:80:29)\n    at D:\\xxx\\xxx\\node_modules\\which\\which.js:89:16\n    at D:\\xxx\\xxx\\node_modules\\isexe\\index.js:42:5\n    at D:\\xxx\\xxx\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed   code: 'ENOENT' }
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:\xxx\xxx\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\xxx\xxx\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\xxx\xxx\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\xxx\xxx\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed  python { Error: not found: python
gyp verb `which` failed     at getNotFoundError (D:\xxx\xxx\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (D:\xxx\xxx\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (D:\xxx\xxx\node_modules\which\which.js:80:29)
gyp verb `which` failed     at D:\xxx\xxx\node_modules\which\which.js:89:16
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at D:\xxx\xxx\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed   stack:
gyp verb `which` failed    'Error: not found: python\n    at getNotFoundError (D:\\xxx\\xxx\\node_modules\\which\\which.js:13:12)\n    at F (D:\\xxx\\xxx\\node_modules\\which\\which.js:68:19)\n    at E (D:\\xxx\\xxx\\node_modules\\which\\which.js:80:29)\n    at D:\\xxx\\xxx\\node_modules\\which\\which.js:89:16\n    at D:\\xxx\\xxx\\node_modules\\isexe\\index.js:42:5\n    at D:\\xxx\\xxx\\node_modules\\isexe\\windows.js:36:5\n    at FSReqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed   code: 'ENOENT' }
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:\xxx\xxx\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (D:\xxx\xxx\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at D:\xxx\xxx\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\xxx\\xxx\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\xxx\xxx\node_modules\node-sass
gyp ERR! node -v v16.13.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

上面报错是因为node版本与nodesass版本不匹配导致的,gyp ERR! node -v v16.13.0中显示出来。
最好的解决方法是在网上搜一下nodesass版本匹配的node版本,比如在package.json里面查看nodesass版本是4.14.0,在网上搜索与之匹配的node版本是14.18.1,而不是16.13.0
然后把尝试用nvm更改node版本,改不掉的话,就直接卸载node版本,下载所需的node版本:查看这里

参考链接:
https://blog.csdn.net/suhanyujie/article/details/119942067
https://www.cnblogs.com/huasonglin/p/14777752.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐