menu

Questions & Answers

ts jest socket timeout error occurred in aws cdk init

I'm trying to install ts-jest package but a socket time error occurred.
I can't execute aws cdk init with this error.

Versions:

npm 8.19.3
cdk 2.60.0
nodejs 18.13.0

I tried to:

1) cdk init sample-app --language typescript
2) npm i -D ts-jest@"<23.10.0"
  • both failed with an error message below.

Error:

npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/ts-jest reason: Invalid response body while trying to fetch https://registry.npmjs.org/ts-jest: aborted

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/{user}/.npm/_logs/2023-01-17T03_04_26_593Z-debug-0.log`

in log:

 1268 1267 verbose stack FetchError: invalid json response body at https://registry.npmjs.org/ts-jest reason: Invalid response body while trying to fetch https://registry.npmjs.org/ts-jest:       Socket timeout
 1269 1267 verbose stack     at Response.json (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:79:13)
 1270 1267 verbose stack     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 1271 1267 verbose stack     at async RegistryFetcher.packument (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25)
 1272 1267 verbose stack     at async RegistryFetcher.manifest (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23)
 1273 1267 verbose stack     at async [nodeFromEdge] (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1061:19)
 1274 1267 verbose stack     at async [buildDepStep] (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:930:11)
 1275 1267 verbose stack     at async Arborist.buildIdealTree (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:211:      7)
 1276 1267 verbose stack     at async Promise.all (index 1)
 1277 1267 verbose stack     at async Arborist.reify (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
 1278 1267 verbose stack     at async Install.exec (/opt/homebrew/Cellar/node@18/18.13.0_1/lib/node_modules/npm/lib/commands/install.js:145:5)

Additional: cdk init stopped in this status: idealTree:cdktest: sill idealTree buildDeps

What am I missing?

I also tried to:

npm cache clean --force

npm config rm proxy

npm config rm https-proxy

npm cache verify
Comments:
2023-01-18 00:25:09
I'm unable to reproduce, and npm doesn't report any incidents with the registry. Are you behind a firewall, on a VPN, or have anything else potentially interfering with your network? Are you able to install other packages? Is there any more useful info in the debug log (printed in the error message)?
2023-01-18 00:25:09
@zac-anger Hello :) Thanks for your reply. I tried to install aws-cdk and aws-cdk-lib packages first and It was successfully installed. I didn't use a VPN. I added more information in my post.
2023-01-18 00:25:09
From the error message and the fact that it hung on a buildDeps, it sounds like either your network connection or possibly your computer aren't keeping up — are you on a reliable connection, and a decently powerful machine?
2023-01-18 00:25:09
@ZacAnger Yes. There is no problem installing the other packages. And I tried to create a cdk project a month ago, but there were no problems. I use an M1 Pro with macOS Monterey.
Answers(0) :