【发布时间】:2012-12-15 23:57:25
【问题描述】:
我目前正在尝试从 URL 导入 one of my scripts,但 require 函数在这种情况下似乎不起作用。
var functionChecker = require("http://javascript-modules.googlecode.com/svn/functionChecker.js");
这是此脚本生成的错误消息的摘录:
Error: Cannot find module 'http://javascript-modules.googlecode.com/svn/functionChecker.js'
有没有办法从 node.js 中的 URL 导入脚本?
【问题讨论】:
-
一种选择是将脚本下载到本地目录,然后像任何其他模块一样导入它。
-
这段代码 sn-p 解决了我的问题:stackoverflow.com/a/4174157/975097
标签: node.js