0
点赞
收藏
分享

微信扫一扫

npm 奇葩错误

兽怪海北 2022-01-30 阅读 55
npm

PS D:\VV9\react-example\imooc\shelley-vikingship> npm install node-sass@4.12.0 --save
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Ma
th.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/m
ath-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/re
quest/issues/3142
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive se
curity updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path D:\VV9\react-example\imooc\shelley-vikingship\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe D:\VV9\react-example\imooc\shelley-vikingship\
node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass
_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\VV9\\react-example\\imooc\\shelley-vikingship\\node_modules\\node-gyp
\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.2 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\VV9\react-example\imooc\shelley-vikin
gship\node_modules\node-gyp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\node-gyp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\VV9\react-example\imooc\shelley-vikin
gship\node_modules\node-gyp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\node-gyp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\VV9\react-example\imooc\shelley-vikin
gship\node_modules\node-gyp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\node-gyp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\VV9\react-example\imooc\shelley-vikin
gship\node_modules\node-gyp\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\VV9\react-example\imooc\shelley-vikingship\node_modu
les\node-gyp\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\node-gyp\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\VV9\react-example\imooc\shelley-vikingship\node_modules
\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb could not find "python". checking python launcher
npm ERR! gyp verb could not find "python". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env v
ariable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:\VV9\react-example\imooc\shelley-vikin
gship\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\VV9\react-example\imooc\shelley-viking
ship\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack     at callback (D:\VV9\react-example\imooc\shelley-vikingship\node_module
s\graceful-fs\polyfills.js:299:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\VV9\\react-example\\imooc\\sh
elley-vikingship\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext="
 "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\VV9\react-example\imooc\shelley-vikingship\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jtsoft\AppData\Local\npm-cache\_logs\2022-01-29T06_37_29_434Z-debug.log

备选方案 1
以管理员身份运行 shell ,只需全局安装构建工具包 (node-gyp README):

npm i -g windows-build-tools
备选方案 2
安装 Visual Studio 有一些逻辑:

通过运行命令验证您是否有 VS 构建工具(如果有,请跳到第 4 步并尝试设置环境变量)
npm config get msvs_version
如果没有安装,VS build tools 工具
运行命令
npm config set msvs_version 2019 --global
安装了 VS 并且没有声明此变量将 VCTargetsPath 环境变量(开始菜单搜索 环境变量)设置为适当的路径(例如 C:\Program Files (x86)\MSBuild\Microsoft\Portable\v5.0 )
注:

以前的错误可能会通过安装来解决 Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019;
您可能还想在安装上述任何一个后重新启动
备选方案3
安装Node的时候勾选 ‘自动安装必要工具’

 参考文档:

gyp ERR!
node.js - How can I solve error gypgyp ERR!ERR! find VSfind VS msvs_version not set from command line or npm config? - Stack Overflow

 安装完nodejs,弹出这个窗口,继续安装呢

安装了vcredist140-x64,python3.10, visualstudio2019buildtools 等等,至少要个20分钟,鹅鹅鹅。最后好像是Windows版本不对什么的,一闪而过。。。。。然后上面的方法都不行,有空再更新。。。。

 https://blog.csdn.net/qq_34707272/article/details/118015209 

举报

相关推荐

0 条评论