[英]Load JavaScript file inside another JS file
I'm using node.js
and socket.io
and doing a server/client thing. 我正在使用
node.js
和socket.io
并进行服务器/客户端操作。 On my Server, is since its' not on a webpage, is there a way I can load the latest file (or latest jQuery?) so I can use jQuery functions inside my Server js file. 在我的服务器上,因为它不在网页上,有没有办法加载最新文件(或最新jQuery?),以便可以在Server js文件中使用jQuery函数。
I tried doing npm install jquery
then drag the jquery
folder into my node_modules
folder onto my website. 我尝试执行
npm install jquery
然后将jquery
文件夹拖到我的node_modules
文件夹中到我的网站上。 Then at he top of my file I put var $ = require('jQuery');
然后在我文件的顶部放
var $ = require('jQuery');
and then I run it and I get the error Cannot find module 'location'
然后运行它,出现错误
Cannot find module 'location'
Thanks 谢谢
I was getting this same issue. 我遇到了同样的问题。 I created a small test applications (with express), installed jquery afresh and things started working.
我创建了一个小型测试应用程序(带有express),重新安装了jquery,事情开始起作用。
Checking my initial project a couple of changes seemed significant 检查我的初始项目,进行了几处更改,这似乎很重要
I think the significant part was removing and reinstalling jsdom and jquery but the others then were required to get things working again. 我认为重要的部分是删除并重新安装了jsdom和jquery,但随后又需要其他才能使事情再次起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.