vue-admin-template-master下载依赖出错最全简洁解决方法

vue-admin-template-master下载依赖出错最全简洁解决方法

前言

我用vscode搭建前端项目的时候,发下载依赖包出错,百度查了很多方法,发现这个方法是可以行的,在此记录下来。

原文:https://blog.csdn.net/weixin_43048780/article/details/121845987

项目场景

vscode搭建 vue-admin-template-master 项目前端页面环境

问题描述

在vscode中导入vue-admin-template-master,下载依赖报错,真的很让人头疼,网上的方法很多,试了好几天,终于解决了。

image-20220929154239777

Building: D:\nodejs\node.exe D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli ‘D:\nodejs\node.exe’,
gyp verb cli ‘D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\node-gyp\bin\node-gyp.js’,
gyp verb cli ‘rebuild’,
gyp verb cli ‘–verbose’,
gyp verb cli ‘–libsass_ext=’,
gyp verb cli ‘–libsass_cflags=’,
gyp verb cli ‘–libsass_ldflags=’,
gyp verb cli ‘–libsass_library=’
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.4.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing “build” directory
gyp verb command configure []
gyp verb check python checking for Python executable “python2” in the PATH
gyp verb which failed Error: not found: python2
gyp verb which failed at getNotFoundError (D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:13:12)
gyp verb which failed at F (D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:68:19)
gyp verb which failed at E (D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:80:29)
gyp verb which failed at D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:89:16
gyp verb which failed at D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\isexe\index.js:42:5
gyp verb which failed at D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\isexe\windows.js:36:5
gyp verb which failed at FSReqCallback.oncomplete (fs.js:175:21)
gyp verb which failed python2 Error: not found: python2
gyp verb which failed at getNotFoundError (D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:13:12)
gyp verb which failed at F (D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:68:19)
gyp verb which failed at E (D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:80:29)
gyp verb which failed at D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\which\which.js:89:16
gyp verb which failed at D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\isexe\index.js:42:5
gyp verb which failed at D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\isexe\windows.js:36:5
gyp verb which failed at FSReqCallback.oncomplete (fs.js:175:21) {undefined
gyp verb which failed code: ‘ENOENT’
gyp verb which failed }
gyp verb check python checking for Python executable “python” in the PATH
gyp verb which succeeded python D:\Anaconda3\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: D:\Anaconda3\python.EXE -c import sys; print “%s.%s.%s” % sys.version_info[:3];
gyp ERR! stack File “”, line 1
gyp ERR! stack import sys; print “%s.%s.%s” % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:303:12)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1051:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command “D:\nodejs\node.exe” “D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\node-gyp\bin\node-gyp.js” “rebuild” “–verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
gyp ERR! cwd D:\Microsoft VS Code\workspace\vue-admin-template-master\node_modules\node-sass
gyp ERR! node -v v14.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN script-ext-html-webpack-plugin@2.0.1 requires a peer of html-webpack-plugin@^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-admin-template@3.8.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 postinstall: node scripts/build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\zhaoqinghonh\AppData\Roaming\npm-cache_logs\2020-06-05T03_46_48_088Z-debug.log

原因分析

1、 npm版本太高,如果换成npm6会解决一些问题

2、 python版本太高,我使用的是python3.7,这里需要python2.x

3、 node-sass安装失败

解决方案

1、使用命令"npm -v": 检查npm版本是否为npm6.x,如果版本太高,使用命令"npm install npm@6.14.10 -g",将npm版本改为npm6.x;

2、重新输入命令“npm install”安装依赖,看是否报错,如果不报错则不需要下面的操作;

3、官网:https://www.python.org/downloads/,下载并安装python2.x,安装后记得配置环境变量;

img

win+r,cmd输入命令python查看python版本是否正确;

python

image-20220929154643893

ctrl + c 退出 python 窗口;

4、 先卸载 node-sass;

npm uninstall node-sass

5、 重新下载node-sass,设置变量 sass_binary_site,指向淘宝镜像地址;

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

6、 输入命令“npm install”,重新安装下载依赖,报警告没有影响;

npm install

7、 输入命令“npm run dev”,启动项目,完成依赖下载;

npm run dev

随笔: “每次归程,都是为了更好出发;每次停歇,都是为了积攒力量。”

posted @ 2022-09-29 16:00  Cream薄荷糖  阅读(585)  评论(0编辑  收藏  举报