vadimdemedes/ink

Out of the box npx typescript app does not work

azcn2503 opened this issue · 1 comments

Installing the app using the npx scaffold:

➜  tunny npx create-ink-app --typescript tunny
npx: installed 265 in 22.459s

  ✔ Copy files
  ✔ Install dependencies
  ✖ Link executable
    → Found 1 error in source/test.tsx:4
Error: Command failed: npm run build
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tunny@0.0.0 build: `tsc && chmod +x dist/cli.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the tunny@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/aaron/.npm/_logs/2023-03-15T21_13_20_601Z-debug.log


> tunny@0.0.0 build /home/aaron/git/tunny
> tsc && chmod +x dist/cli.js

source/test.tsx:4:22 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("ink-testing-library")' call instead.
  To convert this file to an ECMAScript module, add the field `"type": "module"` to '/home/aaron/git/tunny/package.json'.

4 import {render} from 'ink-testing-library';
                       ~~~~~~~~~~~~~~~~~~~~~


Found 1 error in source/test.tsx:4


    at makeError (/home/aaron/.npm/_npx/120773/lib/node_modules/create-ink-app/node_modules/execa/index.js:174:9)
    at /home/aaron/.npm/_npx/120773/lib/node_modules/create-ink-app/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Task.task (/home/aaron/.npm/_npx/120773/lib/node_modules/create-ink-app/index.js:135:6)

Additionally, when trying to run this app:

➜  tunny npm run start

> tunny@0.0.0 start /home/aaron/git/tunny
> npm run build && dist/cli.js


> tunny@0.0.0 build /home/aaron/git/tunny
> tsc && chmod +x dist/cli.js

source/test.tsx:4:22 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("ink-testing-library")' call instead.
  To convert this file to an ECMAScript module, add the field `"type": "module"` to '/home/aaron/git/tunny/package.json'.

4 import {render} from 'ink-testing-library';
                       ~~~~~~~~~~~~~~~~~~~~~


Found 1 error in source/test.tsx:4

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tunny@0.0.0 build: `tsc && chmod +x dist/cli.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the tunny@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/aaron/.npm/_logs/2023-03-15T21_15_46_823Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tunny@0.0.0 start: `npm run build && dist/cli.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the tunny@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/aaron/.npm/_logs/2023-03-15T21_15_46_837Z-debug.log

I experience the same thing in node versions 12 and 16, and from a Mac and Linux host.

I just released an update to create-ink-app in vadimdemedes/create-ink-app#28. If you upgrade to the latest version, you shouldn't see this issue anymore. Thanks for reporting!