伙计们。又是一次愚蠢的问题。
在学习使用 node 和 express 时,我正在研究使用particles.js作为背景。在 github 上提供的文档中,它说要使用:
npm install particles.js
这样做之后,我添加了这个以在我的app.js中调用它:
var particleJS = require("particle.js")
然而,此时,当我尝试运行我的应用程序时,节点错误状态:
ReferenceError:未定义窗口
还有另一个代码块应该被调用来创建这个应该在前端运行的代码块,使用玉文件。
/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
particlesJS.load('particles-js', 'assets/particles.json', function() {
console.log('callback - particles.js config loaded');
});
有几件事我不太确定。首先,从我对 node 的乐趣来看,应该可以在 app.js 中调用npm install模块。所以我觉得它不起作用很奇怪..这是因为有问题的代码不是基于使用像 express 这样的框架吗?
其次,如果是这种情况并且我已经通过 npm 安装了particles.js 模块,为了让jade 能够拾取它,我必须将js 复制到“javascript”公共目录以便它可以找到它?
如果是这样的话,我首先不需要通过 npm 安装它?
这么多问题......对不起。我还在学习,并且在这个方面有点跑来跑去。也许我的逻辑在某个地方是错误的。
任何人都可以帮忙吗?