安装node.js时,使用npm install时会有各种各样的问题,有时一个问题解决了,另一个问题就出来了。
个人的这些问题,1-->最后 就是按顺序发生的问题,很是无语
1、npm install 报 cb.apply is not a function 错
解决办法:
1、先把项目内的 package-lock.json 删除掉,要是有node_moudules 包的话一块删除
2、win + r 打开运行,输入%appdata%
3、删除 npm 和 npm-cache 文件夹
4、执行npm cache clean --force命令
此时应该可以了。
如果还不可以,就执行卸载Node.js重新安装。
如果还是不可以,就使用yarn
安装yarn
npm install -g yarn
yarn install 代替 npm install
或者使用cnpm安装
个人使用的是cnpm安装
安装cnpm:
npm install cnpm -g --registry=https://registry.npm.taobao.org
用cnpm安装依赖:
cnpm install
2、报gyp ERR! stack Error: Can't find Python executable "D:\SystemSoftWare\Python39", you can set the PYTHON env variable.
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "D:\SystemSoftWare\Python39", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (D:\IdeaSpace\Study\renren-fast-vue\node_modules\node-sass\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (D:\IdeaSpace\Study\renren-fast-vue\node_modules\node-sass\node_modules\node-gyp\lib\configure.js:509:16)
。。。。。。
解决办法:
- 安装python2.7版本,不用设置环境变量
- 设置Python2.7版本:npm config set python D:\SystemSoftWare\Python27
-
使用cnpm安装:
安装cnpm: npm install cnpm -g --registry=https://registry.npm.taobao.org 用cnpm安装依赖: cnpm install
3、npm run dev时报Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (83)
Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (83)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.13.1
at module.exports (D:\IdeaSpace\Study\renren-fast-vue\node_modules\_node-sass@4.13.1@node-sass\lib\binding.js:13:13)
at Object.<anonymous> (D:\IdeaSpace\Study\renren-fast-vue\node_modules\_node-sass@4.13.1@node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
。。。。。。
解决办法:
方法一:
1、不用回退node版本,而是升级node-sass。
2、update你的sass版本即可:
npm rebuild node-sass
方法二:自己手动升级:
1、先卸载
npm uninstall --save node-sass
2、清除缓存
npm cache clean -f
3、升级node-sass模块
npm install --save node-sass
最后运行
npm run dev