今天在新的开发环境检出nodejs的前端项目,运行npm run serve启动项目后报:

> Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 14.x

原因:不清楚,可能是因为node-sass与node版本的问题,但是是node-sass安装失败导致的,需成功安装node-sass

处理:

npm i node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

我使用的是这个命令解决的

参考:(40条消息) node-sass安装失败解决方法,终有一款适合我们_小刘先生很努力的博客-CSDN博客_node-sass安装失败

安装node-sass报错,提示node-gyp -v 与node版本不符合解决办法


(40条消息) 安装node-sass报错,提示node-gyp -v 与node版本不符合解决办法_目标前端大佬的博客-CSDN博客

(以下摘自参考文章:https://blog.csdn.net/brenda2314/article/details/105584724) 

npm uninstall node-sass
npm install node-sass

 遂又遇到:

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

 原因:缺少python环境 (可参考npm install - gyp ERR! find Python 解决方案)

处理:

第一种方式:
安装Python及环境变量配置
一定要安装python2.7的版本
环境变量安装可以参考:http://blog.csdn.net/lyj_viviani/article/details/51763101
如果第一种方式不行可以试试第二种方式。
 
第二种方式:
运行下面代码(以管理员身份运行cmd执行)

npm install --global --production windows-build-tools

 遂遇到

Unexpected end of JSON input while parsing near **********

解决执行: `npm cache clean --force`

再次尝试,终于成功

最后再重新执行

npm uninstall node-sass
npm install node-sass

至此解决

Logo

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

更多推荐