npm install时 node-sass npm ERR command failed问题解决

npm install 安装出错问题

显示的错误信息

npm ERR! code 1
npm ERR! path C:\Users\li-671\Downloads\light-blue-vue-admin-master\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe C:\Users\li-671\Downloads\light-blue-vue-admin-master\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'C:\\Users\\li-671\\Downloads\\light-blue-vue-admin-master\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@18.12.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb download using dist-url https://npm.taobao.org/dist
npm ERR! gyp verb find Python Python is not set from command line or npm configuration
npm ERR! gyp verb find Python Python is not set from environment variable PYTHON
npm ERR! gyp verb find Python checking if "python3" can be used
npm ERR! gyp verb find Python - executing "python3" to get executable path
npm ERR! gyp verb find Python - "python3" is not in PATH or produced an error
npm ERR! gyp verb find Python checking if "python" can be used
npm ERR! gyp verb find Python - executing "python" to get executable path
npm ERR! gyp verb find Python - executable path is "C:\ProgramData\Anaconda3\python.exe"
npm ERR! gyp verb find Python - executing "C:\ProgramData\Anaconda3\python.exe" to get version
npm ERR! gyp verb find Python - version is "3.9.12"
npm ERR! gyp info find Python using Python version 3.9.12 found at "C:\ProgramData\Anaconda3\python.exe"
npm ERR! gyp verb get node dir no --target version specified, falling back to host node version: 18.12.1
npm ERR! gyp verb command install [ '18.12.1' ]

出现错误后,找了很多方法,网上关于这个问题的解决方法也很多,尝试了两三天,最后发现了一个终极解决方案,亲测有效!!!,下面是链接。

npm install 时 node-sass npm ERR command failed问题解决

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用的描述,当使用npm install命令,出现了"npm ERR! code 1"和"npm ERR! path D:\....\node-sass"的错误信息。同,引用提供了一种解决方法,即安装指定版本的node-sass。此外,引用也提到了卸载node-sass后,package.json中的node-sass会被删除,可以通过备份恢复package.json文件。 针对"npm ERR! command failed"这个错误信息,可能的原因之一是node-sass安装失败或无法正确运行的问题。为了解决这个问题,可以尝试以下几个方法: 1. 确保你已经安装了最新版本的Node.js。可以通过命令行运行"node -v"来检查当前安装的Node.js版本。如果版本过旧,可以考虑升级到最新版本。 2. 检查你的网络连接是否正常。有候安装过程中会需要下载依赖包,如果网络不稳定或者被墙,可以尝试使用代理或切换网络环境。 3. 清除npm缓存。你可以通过运行"npm cache clean --force"清除npm的缓存,然后再次尝试安装node-sass。 4. 卸载并重新安装node-sass。根据引用的提示,可以尝试使用指定版本的node-sass进行安装。通过运行"npm uninstall node-sass"卸载当前的node-sass,然后使用"npm install node-sass@指定的版本号"安装特定版本的node-sass。 5. 恢复package.json文件。如果在卸载node-sass后,发现package.json中的node-sass被删除了,可以通过之前备份的package.json文件来恢复。将备份文件重命名为package.json,然后重新运行npm install命令。 请注意,这些方法并不一定适用于所有情况,具体解决方案可能因个人情况而异。如果问题仍然存在,可以尝试查看其他相关错误信息,查找更多解决方法,或者在相关社区或论坛上寻求帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值