Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
368 views
in Technique[技术] by (71.8m points)

javascript - Javascript require()函数给出了ReferenceError:require未定义(Javascript require() function giving ReferenceError: require is not defined)

Basically, I am using javascript to scrape data from Google Play store using:

(基本上,我使用javascript从Google Play商店中抓取数据:)

1-Request

(1请求)

2-Cheerios

(2-麦片)

3-QueryString

(3,查询字符串)

I used Google Market API from Github which uses require as following:

(我使用了Github的Google Market API,它使用require如下:)

var request   = require('request');
var cheerio   = require('cheerio');
var qs      = require('querystring');

But I am getting the following

(但我得到以下内容)

ReferenceError: require is not defined ...

(ReferenceError:未定义require ...)

So, I don't have require in javascript which is either new for me or this is something out of the ordinary.

(所以,我没有javascript的要求,这对我来说是新的,或者这是一个与众不同的东西。)

  ask by Hunain Usman translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

RequireJS is a JavaScript file and module loader.

(RequireJS是一个JavaScript文件和模块加载器。)

It is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node.

(它针对浏览器内使用进行了优化,但可以在其他JavaScript环境中使用,例如Rhino和Node。)

Using a modular script loader like RequireJS will improve the speed and quality of your code.

(使用像RequireJS这样的模块化脚本加载器可以提高代码的速度和质量。)

 IE 6+ .......... compatible ? Firefox 2+ ..... compatible ? Safari 3.2+ .... compatible ? Chrome 3+ ...... compatible ? Opera 10+ ...... compatible ? 

http://requirejs.org/docs/download.html

(http://requirejs.org/docs/download.html)

Add this to your project: https://requirejs.org/docs/release/2.3.5/minified/require.js

(将其添加到您的项目: https//requirejs.org/docs/release/2.3.5/minified/require.js)

and take a look at this http://requirejs.org/docs/api.html

(并查看此http://requirejs.org/docs/api.html)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...