内容的栏目 * @param int $category 0列表 1频道 2单页 3外链 * @return array */ function category_list($forumlist, $model = 0, $display = 0, $category = 0) { if (empty($forumlist)) return NULL; static $cache = array(); $key = $model . '-' . $display . '-' . $category; if (isset($cache[$key])) return $cache[$key]; if ($display) { foreach ($forumlist as $k => $val) { if (1 == $val['display'] && 1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } else { foreach ($forumlist as $k => $val) { if (1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } return empty($cache[$key]) ? NULL : $cache[$key]; } /** * @param $forumlist 所有版块列表 不分模型 * @param int $display 0全部CMS栏目 1在首页和频道显示内容的栏目 * @param int $category 0列表 1频道 2单页 3外链 * @return array */ function category_list_show($forumlist, $display = 0, $category = 0) { if (empty($forumlist)) return NULL; static $cache = array(); $key = $display . '-' . $category; if (isset($cache[$key])) return $cache[$key]; if ($display) { foreach ($forumlist as $k => $val) { if (1 == $val['display'] && 1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } else { foreach ($forumlist as $k => $val) { if (1 == $val['type'] && $val['category'] == $category) { $cache[$key][$k] = $val; } } } return empty($cache[$key]) ? NULL : $cache[$key]; } /** * @param $forumlist 所有版块列表 * @return mixed BBS栏目数据(仅列表) 尚未开放bbs频道功能 */ function forum_list($forumlist) { if (empty($forumlist)) return array(); static $cache = array(); if (isset($cache['bbs_forum_list'])) return $cache['bbs_forum_list']; $cache['bbs_forum_list'] = array(); foreach ($forumlist as $_fid => $_forum) { if ($_forum['type']) continue; $cache['bbs_forum_list'][$_fid] = $_forum; } return $cache['bbs_forum_list']; } // 导航显示的版块 function nav_list($forumlist) { if (empty($forumlist)) return NULL; static $cache = array(); if (isset($cache['nav_list'])) return $cache['nav_list']; foreach ($forumlist as $fid => $forum) { if (0 == $forum['nav_display']) { unset($forumlist[$fid]); } } return $cache['nav_list'] = $forumlist; } ?>javascript - Module not found: Can't resolve 'readline' - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Module not found: Can't resolve 'readline' - Stack Overflow

programmeradmin0浏览0评论

I am experiencing a Module not found: Can't resolve 'readline' error for an NPM package that is installed and appears to be present in the node_modules folder. Place of the error:

module "c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index"
Could not find a declaration file for module 'athena-express'. 'c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index.js' implicitly has an 'any' type.
  Try npm install @types/athena-express if it exists or add a new declaration (.d.ts) file containing declare module athena-express';ts(7016) 

Tried import and require the module but still have the same error. Used "create react app" to create react app. Also tried everything above. Below code trying query s3 with Athena.

const AthenaExpress = require('athena-expresss');
const aws = require('aws-sdk');

aws.config.update(awsCredentials);

const athenaExpressConfig = {
  aws,
  s3: "s3://result-bucket-cdr/",
  getStats: true
};

const athenaExpress = new AthenaExpress(athenaExpressConfig);

(async () => {
  let query = {
    sql: "SELECT * from result",
    db: "default",
    getStats: true 
  };

  try {
    let results = await athenaExpress.query(query);
    console.log(results);
  } catch (error) {
    console.log(error);
  }
})();

Expect works without the error but have the error

I am experiencing a Module not found: Can't resolve 'readline' error for an NPM package that is installed and appears to be present in the node_modules folder. Place of the error:

module "c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index"
Could not find a declaration file for module 'athena-express'. 'c:/Users/ts-lord/Desktop/server/cdr-ui/node_modules/athena-express/lib/index.js' implicitly has an 'any' type.
  Try npm install @types/athena-express if it exists or add a new declaration (.d.ts) file containing declare module athena-express';ts(7016) 

Tried import and require the module but still have the same error. Used "create react app" to create react app. Also tried everything above. Below code trying query s3 with Athena.

const AthenaExpress = require('athena-expresss');
const aws = require('aws-sdk');

aws.config.update(awsCredentials);

const athenaExpressConfig = {
  aws,
  s3: "s3://result-bucket-cdr/",
  getStats: true
};

const athenaExpress = new AthenaExpress(athenaExpressConfig);

(async () => {
  let query = {
    sql: "SELECT * from result",
    db: "default",
    getStats: true 
  };

  try {
    let results = await athenaExpress.query(query);
    console.log(results);
  } catch (error) {
    console.log(error);
  }
})();

Expect works without the error but have the error

Share Improve this question edited Feb 4, 2020 at 14:14 ns16 1,5602 gold badges20 silver badges29 bronze badges asked Jun 12, 2019 at 8:49 Serhii ZadorozhnyiSerhii Zadorozhnyi 6262 gold badges10 silver badges25 bronze badges 4
  • readline is a node core library. Could you update your question with versions of node, React, create-react-app etc? And also please post the entire error stack, atleast relevant parts of it and by that I mean where it occurred etc. – PrivateOmega Commented Jun 12, 2019 at 8:53
  • Is this the whole code? can't find where you have used 'readline'. – Anjana Commented Jun 12, 2019 at 8:53
  • I didn't use 'readline'. Node.js is using 'readline' for reading data from a Readable stream – Serhii Zadorozhnyi Commented Jun 12, 2019 at 8:55
  • Kindly suggest you to refer this stackoverflow./questions/41292559/… – Anjana Commented Jun 12, 2019 at 10:33
Add a ment  | 

1 Answer 1

Reset to default 4

The readline issue could be resolved by npm installing readline. This seems to be a mon issue with create-react-app. Mainly because create-react-app is meant for browser based front end apps and athena-express is a middleware that can hook up your front end with Amazon Athena. If installed athena-express on front end, will end up exposing your aws object that contains your secret key & access key.

Best bet is to create a simple node.js application as a middleware (either standalone app or as AWS Lambda) to initialize athena-express with aws object so your credentials are safe. Then you can invoke athena-express as an API from your browser react app.

发布评论

评论列表(0)

  1. 暂无评论