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版本…然后行了