最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

在Node Repl中使用.load函数的问题

IT培训 admin 9浏览 0评论

在Node Repl中使用.load函数的问题

我正在运行Nodejs并尝试使用以下命令在repl中加载脚本:.load transformscript.js

transformscript.js中的前两行如下:.load rdfMapping.js .load rdfVocab.js

问题是我收到错误'SyntaxError:Unexpected token'。在第一行。有人知道为什么会这样,因为我对Node和repl没有多少经验。

回答如下:

您只能在REPL控制台中使用.load path_to_the_module命令。要在文件脚本中加载模块,您需要使用require('path_to_the_module')

所以transformscript.js的第一行应该是:

require('./rdfMapping.js');
require('./rdfVocab.js');

在Node Repl中使用.load函数的问题

我正在运行Nodejs并尝试使用以下命令在repl中加载脚本:.load transformscript.js

transformscript.js中的前两行如下:.load rdfMapping.js .load rdfVocab.js

问题是我收到错误'SyntaxError:Unexpected token'。在第一行。有人知道为什么会这样,因为我对Node和repl没有多少经验。

回答如下:

您只能在REPL控制台中使用.load path_to_the_module命令。要在文件脚本中加载模块,您需要使用require('path_to_the_module')

所以transformscript.js的第一行应该是:

require('./rdfMapping.js');
require('./rdfVocab.js');
发布评论

评论列表 (0)

  1. 暂无评论