问题:vue cli 创建项目出现无法创建成功报错
not found: python2.7等问题
描述:
vue create test
正常创建,在建立依赖时出现问题导致错误输出
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@14.8.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.7" in the PATH
gyp verb `which` failed Error: not found: python2.7
gyp verb `which` failed at getNotFoundError (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:176:21)
gyp verb `which` failed python2.7 Error: not found: python2.7
gyp verb `which` failed at getNotFoundError (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:176:21) {
gyp verb `which` failed code: 'ENOENT'
gyp verb `which` failed }
gyp verb could not find "python2.7". checking python launcher
gyp verb could not find "python2.7". 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 "python2.7", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at callback (C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:176:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Sparkle\\Desktop\\Vue\\sparkle\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Sparkle\Desktop\Vue\sparkle\node_modules\node-sass
gyp ERR! node -v v14.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
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\Sparkle\AppData\Roaming\npm-cache\_logs\2020-08-20T03_07_25_916Z-debug.log
ERROR command failed: npm install --loglevel error
定位问题:
gyp verb check python checking for Python executable "python2.7" in the PATH
gyp verb `which` failed Error: not found: python2.7
找不到python27
尝试解决方案:安装python27,设置环境变量
新问题出现;缺少vs,
尝试解决办法:安装vs设置环境变量,
不停出现新问题,解决方案废弃
尝试解决方案:安装windows-build-tools
npm --add-python-to-path='true' --debug install --global windows-build-tools
出错:非必要懒得看什么问题了
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this
> windows-build-tools@5.2.2 postinstall C:\Users\Sparkle\AppData\Roaming\npm\node_modules\windows-build-tools
> node ./dist/index.js
nugget start dl https://npm.taobao.org/mirrors/python/2.7.15/python-2.7.15.amd64.msi +0ms
Downloading python-2.7.15.amd64.msi
Downloading python-2.7.15.amd64.msi
[> ] 0.0% (0 B/s)
Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\Sparkle\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
[> ] 0.0% (0 B/s)
Downloading vs_BuildTools.exe
[> ] 0.0% (0 B/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\Sparkle\.windows-build-tools\vs_BuildTools.exe.
Starting installation...
windows-build-tools Installer: Launching installer in C:\Users\Sparkle\.windows-build-tools with parameters -ExecutionPolicy,Bypass,-NoProfile,-NoLogo,& {& 'C:\Users\Sparkle\AppData\Roaming\npm\node_modules\windows-build-tools\ps1\launch-installer.ps1' -BuildToolsInstallerPath 'C:\Users\Sparkle\.windows-build-tools' -InstallBuildTools -ExtraBuildToolsParameters '' -PythonInstaller 'python-2.7.15.amd64.msi' -InstallPython -VisualStudioVersion '2017' }. +0ms
events.js:291
throw er; // Unhandled 'error' event
^
Error: spawn powershell.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:268:19)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
at onErrorNT (internal/child_process.js:468:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn powershell.exe',
path: 'powershell.exe',
spawnargs: [
'-ExecutionPolicy',
'Bypass',
'-NoProfile',
'-NoLogo',
"& {& 'C:\\Users\\Sparkle\\AppData\\Roaming\\npm\\node_modules\\windows-build-tools\\ps1\\launch-installer.ps1' -BuildToolsInstallerPath 'C:\\Users\\Sparkle\\.windows-build-tools' -InstallBuildTools -ExtraBuildToolsParameters '' -PythonInstaller 'python-2.7.15.amd64.msi' -InstallPython -VisualStudioVersion '2017' }"
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! windows-build-tools@5.2.2 postinstall: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the windows-build-tools@5.2.2 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\Sparkle\AppData\Roaming\npm-cache\_logs\2020-08-20T03_32_04_165Z-debug.log
直接废弃
灵感
node-sass安装失败,安装后无法使用
问题重定位:建立阶段没有问题,已成功生成项目文件,但无法run serve,问题出在依赖建立上
解决实现:执行npm install报错Error: not found: python2
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install node-sass
cnpm instal
思路解释:项目文件既然已经存在,进入项目文件夹,使用淘宝镜像,cnpm的方式更新创建node-sass,在项目文件下用cnpm构建项目依赖
问题解决
//项目文件下运行
npm run serve