栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

开源项目部署前端时候遇到的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 FilesPython36python.EXE
gyp verb check python version `C:Program FilesPython36python.EXE -c "import platform; print(platform.python_version());"` returned: "3.6.4rn"
gyp verb could not find "C:Program FilesPython36python.EXE". checking python launcher
gyp verb could not find "C:Program FilesPython36python.EXE". guessing location
gyp verb ensuring that file exists: C:Python27python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:Program FilesPython36python.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:Users314niuniuDesktopchromedriver_win32.zip

驱动安装好了

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

报错信息如下:

Building: C:Program Filesnodejsnode.exe E:blog_webvue-admin-template-masternode_modulesnode-gypbinnode-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_webvue-admin-template-masternode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexeindex.js:42:5
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexewindows.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_webvue-admin-template-masternode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexeindex.js:42:5
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexewindows.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_webvue-admin-template-masternode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexeindex.js:42:5
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexewindows.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_webvue-admin-template-masternode_moduleswhichwhich.js:13:12)
gyp verb `which` failed     at F (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:68:19)
gyp verb `which` failed     at E (E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:80:29)
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_moduleswhichwhich.js:89:16
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexeindex.js:42:5
gyp verb `which` failed     at E:blog_webvue-admin-template-masternode_modulesisexewindows.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:Python27python.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_webvue-admin-template-masternode_modulesnode-gyplibconfigure.js:484:19)
gyp ERR! stack     at PythonFinder. (E:blog_webvue-admin-template-masternode_modulesnode-gyplibconfigure.js:509:16)
gyp ERR! stack     at callback (E:blog_webvue-admin-template-masternode_modulesgraceful-fspolyfills.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_webvue-admin-template-masternode_modulesnode-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_moduleswebpack-dev-servernode_modulesfsevents):
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_moduleswatchpack-chokidar2node_modulesfsevents):
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_modulesfsevents):
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:UsersMACHENIKEAppDataRoamingnpm-cache_logs2020-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 竟然神奇的好了


终于大功告成,完结撒花
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/269295.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号