开源项目部署前端时候遇到的npm install相关的问题记录

跑前端的vue项目的时候踩了很多坑,记录一下

  1. 刚开始安装了node.js

在这里插入图片描述

  1. 然后我就去执行了 npm install

  2. 然后就报了下面一堆的错

在这里插入图片描述

  1. 然后我就把镜像换成了淘宝的镜像

    npm get registry
    https://registry.npmjs.org/(npm默认镜像源)
    
    npm config set registry https://registry.npm.taobao.org
    
  2. 然后还安装了一个cnpm,然后执行 cnpm install 结果又报错
    在这里插入图片描述

  3. 然后看到网上说,可能是因为npm的版本太高,不能用7.XX,要降到6.XX,于是我降了版本

win+R 输入 npm-v  是否版本号大于等于7,使用:
	npm install -g npm@6  
进行版本回退

降完版本后:
在这里插入图片描述

  1. 再次执行cnpm install,出现如下错误
    Not Found - GET https://registry.npm.taobao.org/@types/strip-json-comments/-/strip-json-comments-0.0
  2. 换成执行npm install

完了又报如下错误:

gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Program Files\Python36\python.EXE
gyp verb check python version `C:\Program Files\Python36\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.4\r\n"
gyp verb could not find "C:\Program Files\Python36\python.EXE". checking python launcher
gyp verb could not find "C:\Program Files\Python36\python.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Program Files\Python36\python.EXE", you can set the PYTHON env variable.

解决办法:

There is another workaround to this error:

  1. Delete your folder.node_modules
  2. Run in your command prompt. npm install --global windows-build-tools --save
  3. Install node-sass using the command: (or the latest version)npm install node-sass@4.12.0 --save

完了又出现如下错误:
在这里插入图片描述

解决办法:

1 先删除 node_modules 文件夹,不然运行的时候可能会报错
2 手动下载chromedriver的压缩包,放在一个地方(我这里放在了桌面)

下载地址:

https://cdn.npm.taobao.org/dist/chromedriver/2.27/chromedriver_win32.zip

3、执行下面命令:

npm install chromedriver --chromedriver_filepath=C:\Users\314niuniu\Desktop\chromedriver_win32.zip

驱动安装好了
在这里插入图片描述

  1. 到这里看似完事大吉,浏览器启动起来,也开始编译代码了,可谁曾想到,编译到最后又报了node-nass的错误,我一看头都炸了,这错误不就是最初的时候一直报的跟他有关的错嘛,一夜又回到解放前了?

报错信息如下:

Building: C:\Program Files\nodejs\node.exe E:\blog_web\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   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'E:\\blog_web\\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@12.18.2 | 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 (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21) {
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` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\blog_web\vue-admin-template-master\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\blog_web\vue-admin-template-master\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location 
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (E:\blog_web\vue-admin-template-master\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (E:\blog_web\vue-admin-template-master\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (E:\blog_web\vue-admin-template-master\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:167:21)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\blog_web\\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 E:\blog_web\vue-admin-template-master\node_modules\node-sass
gyp ERR! node -v v12.18.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN notsup Unsupported engine for watchpack-chokidar2@2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"12.18.2","npm":"6.14.5"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2@2.0.0
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@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 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@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 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\MACHENIKE\AppData\Roaming\npm-cache\_logs\2020-07-07T15_30_39_533Z-debug.log
  1. 谁曾想到,又执行了如下两行命令
1、npm install -g mirror-config-china --registry=http://registry.npm.taobao.org

2、npm install node-sass
  1. 再次执行 npm run dev 竟然神奇的好了


终于大功告成,完结撒花

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值