简体   繁体   English

当子模块构建失败时,NPM为什么会成功?

[英]Why does NPM success when submodules fail to build?

Often while using npm I've come across errors that appear to mean nothing - Visual Studio projects failing to build, build tools (eg: python.exe / CL.exe) not being available on the command line etc. 通常在使用npm时,我会遇到似乎毫无意义的错误-Visual Studio项目无法生成,无法在命令行上使用(例如:python.exe / CL.exe)生成工具等。

Some examples of packages I've seen fail to build many times: 我见过的一些软件包示例无法多次构建:

  • kerberos kerberos
  • node-gyp 节点石膏
  • bcrypt 加密

These throw big error messages with stack traces etc to the console during npm install , clearly having failed completely; 这些在npm install期间npm install带有堆栈跟踪等的大错误消息抛出到控制台,显然完全失败了; however, NPM carries along happy as Larry and 9 times out of 10 my Javascript application and all its dependencies work fine. 但是,在我的Javascript应用程序中,NPM和Larry的关系非常愉快,十分之九。

  1. Does npm install re-build every single dependency recursively, using whatever compilers are available on the local machine? npm install是否使用本地计算机上可用的任何编译器以递归方式重新构建每个依赖关系?

  2. If so, and considering the huge number of dependencies even simple packages can have, how am I able to do ANYTHING without a full suite of programming languages and compilers installed? 如果是这样,并且考虑到甚至简单的软件包都可能具有的大量依赖关系,那么在没有安装全套编程语言和编译器的情况下,我怎么能做任何事情?

  3. Why is it that these dependencies failing doesn't necessarily mean my final project will be unusable? 为什么这些依赖项失败并不一定意味着我的最终项目将无法使用?

  4. If a dependency failing to build is "ok", why bother having the dependency at all? 如果不能建立依赖项是“好的”,那为什么还要麻烦这个依赖项呢?

I haven't been able to find clear answers on any of this, due to the overwhelming number of resources found when searching for terms like "npm build fail". 由于在搜索“ npm build fail”之类的术语时发现了大量的资源,因此我无法找到任何明确的答案。

npm will succeed if those dependencies are actually marked as optional. 如果这些依赖项实际上标记为可选,则npm将成功。 The ws module is an example of this where they have optional dependencies on two compilable addons. ws模块就是其中的一个示例,其中它们对两个可编译插件具有可选的依赖关系。 If they fail to build, then ws just uses pure js fallback implementations. 如果它们无法构建,则ws仅使用纯js后备实现。

The reason that addons are sometimes added as optional dependencies is that the they (more often than not) perform faster than the pure js alternatives, even for something as "simple" as UTF-8 validation or XOR'ing the contents of a Buffer. 有时将插件添加为可选依赖项的原因是,它们(通常不是)的执行速度比纯js替代方法要快,即使对于像“简单”这样的UTF-8验证或对缓冲区内容进行XOR运算也是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当项目在其他文件夹中构建时,为什么React Web App的Webpack构建会失败? - Why does Webpack build of React web app fail when project is built in a different folder? 为什么我的相机在我的 Android EAS 构建上运行时无法打开? - Why does my camera fail to open when being run on my Android EAS build? 为什么“npm run build”在使用@wordpress/scripts 时不会生成 *.asset.php? - Why "npm run build" does not generate *.asset.php when working with @wordpress/scripts? 为什么 JSON.parse(“foo”) 失败但 JSON.parse('“foo” ') 成功? - Why does JSON.parse(“foo”) fail but JSON.parse(' “foo” ') success? 使用devDependencies部署NPM包时,何时进行构建? - When does a build happen when you deploy a NPM package with devDependencies? 如何修复 NPM 安装 SQLite 构建失败? - How to fix NPM install SQLite build fail? 为什么我在运行时收到此错误:npm run build? - Why am I getting this error when running: npm run build? 什么时候 is.then(success, fail) 被认为是 promise 的反模式? - When is .then(success, fail) considered an antipattern for promises? JavaScript“如果” - 为什么它不会失败? - JavaScript “If” - Why does it not fail? 为什么这个JavaScript会失败? - Why does this JavaScript fail?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM