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' ]

版本问题
可能是node.js的版本和node-sass的版本不合

解决方法
所以要更改自己的node.js的版本,就是卸掉原来的node.js,下一个符合node-sass版本的node.js

卸掉原来的node.js
就直接卸

查看需要的node-sass的版本
在package.json文件中找到node-sass": “^版本号”,记下版本号

根据node-sass的版本找到合适的node.js版本下载

然后到这里去查看合适node-sass的版本的node.js版本并下载安装.

比如说node-sass是4.9.3就找node10,node module是64的

安装新的node.js
卸掉之前装的node-sass

npm uninstall node-sass

查看node-sass版本

node-sass -v

还能看到说明没卸掉,就得另外找原因了

安装指定版本的node-sass

 npm install node-sass@指定的版本号

同样可以检查版本号,看是否安装成功

然后就可以继续安装依赖
如果之前node-modules文件夹在,也可以先删了再装

npm install

但是有时候还会产生额外问题,如卸载node-sass时,npm does not support Node.jsxxx,就npm和node.js的版本不匹配,又得换npm的版本

额外问题
npm的版本和node.js的版本不合,然后无法卸掉不合适的node-sass版本

找到合适的npm
根据node.js的版本找到合适的npm的版本号,记下来.

然后切换npm版本的方法是

npm install -g npm@版本号

然后还是切换不了,说是node.js版本不对
所以我又试着装回以前的node.js版本,然后把npm的版本换掉,然后再改变node.js版本…然后行了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: 当npm出现ENOENT错误,通常是由于找不到文件引起的。可能是路径不正确,需要确保在项目的根路径下运行命令,例如vue的启动命令一般是npm run dev / npm run serve,而react的启动命令是npm start。另外,也可能是因为安装的版本不匹配,可以尝试安装对应版本的插件。如果是安装其他包出现错误,可能是安装的版本太高与当前项目不匹配。123 #### 引用[.reference_title] - *1* [Vue脚手架报错:npm ERR! code ENOENTnpm ERR! syscall opennpm ERR!](https://blog.csdn.net/weixin_56035334/article/details/125265069)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *2* [【 npm ERR! code ENOENT npm ERR! syscall open npm ERR!项目运行报错问题】](https://blog.csdn.net/m0_45991266/article/details/131060804)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] - *3* [npm install 报错(npm ERR! code EPERM npm ERR! syscall mkdir npm ERR! path D:\node.js\odejs)](https://blog.csdn.net/weixin_56661658/article/details/128512027)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值