【问题标题】:Everytime I Try To Run NPM Install Terminal throws several errors每次我尝试运行 NPM 安装终端都会抛出几个错误
【发布时间】:2021-01-22 15:05:55
【问题描述】:

这是在我的工作笔记本电脑上。我有 angular、Nodejs、Nodesass、VScode 的最新版本,并且在本地环境路径中也提到了它们。如果我从 Github 下载任何 Angular 模板并尝试进行 NPM 安装,它总是会抛出这些错误。我该怎么做才能修复这些错误?

//        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:\Interview\node_modules\which\which.js:13:12)
//        gyp verb `which` failed     at F (D:\Interview\node_modules\which\which.js:68:19)
//        gyp verb `which` failed     at E (D:\Interview\node_modules\which\which.js:80:29)
//        gyp verb `which` failed     at D:\Interview\node_modules\which\which.js:89:16
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\index.js:42:5
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\windows.js:36:5
//        gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199:21)
//        gyp verb `which` failed  python2 Error: not found: python2
//        gyp verb `which` failed     at getNotFoundError (D:\Interview\node_modules\which\which.js:13:12)
//        gyp verb `which` failed     at F (D:\Interview\node_modules\which\which.js:68:19)
//        gyp verb `which` failed     at E (D:\Interview\node_modules\which\which.js:80:29)
//        gyp verb `which` failed     at D:\Interview\node_modules\which\which.js:89:16
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\index.js:42:5
//        gyp verb `which` failed     at D:\Interview\node_modules\isexe\windows.js:36:5
//        gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:199: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` succeeded python C:\Program Files (x86)\Python38-32\python.EXE
//        gyp ERR! configure error 
//        gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python38-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];       
//        gyp ERR! stack   File "<string>", 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 (node:child_process:333:12)
//        gyp ERR! stack     at ChildProcess.emit (node:events:376:20)
//        gyp ERR! stack     at maybeClose (node:internal/child_process:1063:16)
//        gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
//        gyp ERR! System Windows_NT 10.0.18363
//        gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Interview\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
//        gyp ERR! cwd D:\Interview\node_modules\node-sass
//        gyp ERR! node -v v15.5.1
//        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.

【问题讨论】:

  • 正如它所说的未找到python2,所以您尝试安装的库似乎要求您在机器上安装python
  • 我已经安装了 Python 3.8,我还应该安装 py 2 吗?
  • gyp verb which failed python2 Error: not found: python2 所以我认为它需要 python2
  • Python3 与 Python2 完全不兼容。很多 Python2 脚本无法在 Python3 上运行。如果您是 javascript 程序员,我知道这是一个奇怪的概念,因为您可以使用 1998 年编写的 javascript,它可能仍然可以在现代浏览器中工作,但大多数编程语言并不关心向后兼容性。在这种情况下,Javascript 是奇怪的。不能运行旧代码其实很正常
  • npm 缓存验证 && npm install 不起作用?

标签: javascript node.js angular npm


【解决方案1】:

我认为您正在使用 Windows 进行开发。在机器上本地构建所需的一些 node.js 模块。所以,这就是它需要 python 2.x 版和其他工具的原因。

windows-build-tools package install required tools to build module locally. Go ahead and install this package and after installing it then try again running the command npm install command

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-02
    • 2021-10-17
    相关资源
    最近更新 更多