简体   繁体   English

为什么依赖性问题会导致在Meteor项目中的javascript代码无法正常运行?

[英]Why do dependency problems cause javascript code not to run properly when within a Meteor project?

I have been trying to port HTML5 with js code into Meteor. 我一直在尝试将带有js代码的HTML5移植到Meteor中。 I'm having Javascript dependency problems. 我遇到了Javascript依赖问题。

The code can be found at: https://github.com/cwilso/Audio-Input-Effects 可以在以下位置找到该代码: https : //github.com/cwilso/Audio-Input-Effects

I created a new basically empty meteor project (which runs fine) and then added all of the js files from the repo above (which also runs fine on its own). 我创建了一个新的基本为空的流星项目(运行良好),然后从上面的存储库中添加了所有js文件(也可以独立运行)。

In order to make sure that the load order was correct, I renamed all the js files using numeric prefixes so that they would definitely be in the same order that they are loaded in the github repo. 为了确保加载顺序正确,我使用数字前缀对所有js文件进行了重命名,以便它们绝对与在github存储库中加载的顺序相同。 Looking forward to Meteor coming up with a better solution to this particular issue. 期待Meteor为这个特定问题提出更好的解决方案。 I made a local copy of one js file that was otherwise loaded from a url in the repo. 我制作了一个js文件的本地副本,该文件原本是从仓库中的URL加载的。

In order to try to initialize the js I also added a file hello.js: if (Meteor.isClient) { 为了尝试初始化js,我还添加了一个文件hello.js:if(Meteor.isClient){

  Meteor.startup(function () {
    // code to run on server at startup
    initAudio;
  });
}

When meteor runs and I look in the console, I get the following errors: 流星运行并在控制台中查看时,出现以下错误:

Uncaught TypeError: o3djs.provide is not a function (120_shader.js)
Uncaught ReferenceError: initAudio is not defined (hello.js)
Uncaught ReferenceError: Matrix4x4 is not defined (110_visualizer.js)

Thank you for your help. 谢谢您的帮助。

通过将所有js源文件以正确的顺序放入单个js文件中,我能够解决此问题。

Anybody still wanting information regarding meteor load order, Scotch.io wrote an update to the official docs which clears it up somewhat. 任何仍然需要有关流星加载顺序的信息的人,Scotch.io都对官方文档进行了更新,从而对其进行了一定程度的清除。

https://github.com/meteor/meteor/commit/a5bdf481dfece9ebc57107d71be478f9b48cbd1e https://github.com/meteor/meteor/commit/a5bdf481dfece9ebc57107d71be478f9b48cbd1e

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM