{"id":19030038,"url":"https://github.com/statico/nextjs-with-async-lib","last_synced_at":"2025-08-19T11:12:22.709Z","repository":{"id":52327188,"uuid":"129849809","full_name":"statico/nextjs-with-async-lib","owner":"statico","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-30T18:39:00.000Z","size":90,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-21T20:15:09.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/statico.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-17T05:16:00.000Z","updated_at":"2018-04-17T05:29:08.000Z","dependencies_parsed_at":"2022-08-30T17:50:32.190Z","dependency_job_id":null,"html_url":"https://github.com/statico/nextjs-with-async-lib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/statico/nextjs-with-async-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statico%2Fnextjs-with-async-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statico%2Fnextjs-with-async-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statico%2Fnextjs-with-async-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statico%2Fnextjs-with-async-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/statico","download_url":"https://codeload.github.com/statico/nextjs-with-async-lib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/statico%2Fnextjs-with-async-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271143398,"owners_count":24706346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T21:16:17.495Z","updated_at":"2025-08-19T11:12:22.679Z","avatar_url":"https://github.com/statico.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nextjs with async library demo\n\n## Problem\n\nI need a library to be accessible from Node on the server-side and from NextJS React pages.\n\nI would like to take advantage of the new async/await syntax because it makes the code remarkably cleaner and easier to debug.\n\n## Bug\n\nThis demo shows weirdness when trying to include a JavaScript library with async functions inside of a NextJS page:\n\n```\n$ yarn install\n$ yarn exec next\n WARNING  Compiled with 2 warnings\n\n warning  in ./pages/index.js\n\n24:18-21 \"export 'foo' was not found in '../lib/test'\n\n warning  in ./pages/index.js\n\n24:62-65 \"export 'foo' was not found in '../lib/test'\n\nTypeError: Cannot assign to read only property 'exports' of object '#\u003cObject\u003e'\n...\n```\n\nAnd visiting http://localhost:3000 --\n\n![](https://i.imgur.com/n1aSUY2.png)\n\nI can't change `lib/test.js` to ES6-style `export`s because Node will complain with `SyntaxError: Unexpected token`. What am I doing wrong?\n\n### Versions\n\n- NextJS 5.1\n- Node 9.11.1\n\n### Related issues\n\n- https://github.com/webpack/webpack/issues/4039\n- https://github.com/zeit/next.js/issues/3650\n- https://github.com/zeit/next.js/issues/1472\n- https://github.com/zeit/next.js/issues/1735\n\n### pages/index.js\n\n```javascript\nimport { foo } from '../lib/test'\n\nexport default () =\u003e \u003cdiv\u003ehello {String(typeof foo)}\u003c/div\u003e\n```\n\n### lib/test.js\n\n```javascript\nasync function foo () {}\n\nmodule.exports = { foo }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatico%2Fnextjs-with-async-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstatico%2Fnextjs-with-async-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstatico%2Fnextjs-with-async-lib/lists"}