Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postinstall causing error when npm install (ts-patch not found) #764

Closed
ninthsun91 opened this issue Aug 18, 2023 · 3 comments
Closed

postinstall causing error when npm install (ts-patch not found) #764

ninthsun91 opened this issue Aug 18, 2023 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@ninthsun91
Copy link

📝 Summary

  • Typia Version: 4.1.2
  • Expected behavior: npm install
  • Actual behavior: npm install fails with ts-patch not found error

Description

I am making a cli application and published to npm. However, I cannot install the package in global or in a project without ts-patch and typescript pre-installed because typia had added postinstall script inpackage.json requiring ts-patch.

npm install fails with

npm ERR! code 127
npm ERR! path /Users/me/.nvm/versions/node/v18.13.0/lib/node_modules/gitove
npm ERR! command failed
npm ERR! command sh -c -- ts-patch install
npm ERR! sh: ts-patch: command not found

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/me/.npm/_logs/2023-08-18T19_11_01_832Z-debug-0.log

error log indicating postinstall is the cause

539 info run [email protected] postinstall node_modules/gitove ts-patch install
540 info run [email protected] postinstall { code: 127, signal: null }
541 timing reify:rollback:createSparse Completed in 313ms
542 timing reify:rollback:retireShallow Completed in 0ms
543 timing command:i Completed in 9053ms
544 verbose stack Error: command failed
544 verbose stack     at ChildProcess.<anonymous> (/Users/me/.nvm/versions/node/v18.13.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
544 verbose stack     at ChildProcess.emit (node:events:513:28)
544 verbose stack     at maybeClose (node:internal/child_process:1091:16)
544 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
544 verbose stack     at Socket.emit (node:events:513:28)
544 verbose stack     at Pipe.<anonymous> (node:net:320:12)
545 verbose pkgid [email protected]
546 verbose cwd /Users/me/gitove
547 verbose Darwin 22.5.0
548 verbose node v18.13.0
549 verbose npm  v8.19.3
550 error code 127
551 error path /Users/me/.nvm/versions/node/v18.13.0/lib/node_modules/gitove
552 error command failed
553 error command sh -c -- ts-patch install
554 error sh: ts-patch: command not found
555 verbose exit 127
556 timing npm Completed in 9146ms
557 verbose unfinished npm timer reify 1692385861926
558 verbose unfinished npm timer reify:build 1692385870647
559 verbose unfinished npm timer build 1692385870647
560 verbose unfinished npm timer build:deps 1692385870647
561 verbose unfinished npm timer build:run:postinstall 1692385870652
562 verbose unfinished npm timer build:run:postinstall:node_modules/gitove 1692385870652
563 verbose code 127

Reproduction

You can try the error by installing [email protected]

$ npm install [email protected]
or
$ npm install -g [email protected]

The latest version has removed postinstall script added by typia setup. However, if you want the actual source code for the error I can make you a branch.

Question

I don't understand npm scripts lifecycle well yet, but do you need "postinstall": "ts-patch install" even after the initial setup? If not, I think it is better to remove it from the scripts, as this may cause wrong dependency issue. Because of this script trying to setup ts-patch for npm install command, the package has dependency on ts-patch and typescript even when they are listed in devDependencies.

Thank you, and I really love your work!

@samchon
Copy link
Owner

samchon commented Sep 9, 2023

But without ts-patch, it is not possible to perform AOT compilation.

TypeScript is preparing to support formal transformation. Until that, no way to avoid using that script.

microsoft/TypeScript#54276

@samchon samchon self-assigned this Sep 9, 2023
@samchon samchon added the question Further information is requested label Sep 9, 2023
@samchon samchon closed this as completed Sep 10, 2023
@hax
Copy link

hax commented Sep 20, 2023

I just removed postinstall scripts and it seems current version of typia do not need tspatch anymore ?

@samchon
Copy link
Owner

samchon commented Sep 20, 2023

Requires ts-patch still unless using generation mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants