[英]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: 我见过的一些软件包示例无法多次构建:
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的关系非常愉快,十分之九。
Does npm install
re-build every single dependency recursively, using whatever compilers are available on the local machine? npm install
是否使用本地计算机上可用的任何编译器以递归方式重新构建每个依赖关系?
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? 如果是这样,并且考虑到甚至简单的软件包都可能具有的大量依赖关系,那么在没有安装全套编程语言和编译器的情况下,我怎么能做任何事情?
Why is it that these dependencies failing doesn't necessarily mean my final project will be unusable? 为什么这些依赖项失败并不一定意味着我的最终项目将无法使用?
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.