Failing 😢
node 14.15.0 npm 6.14.8
npx typescript-run otp.ts
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '/root/.npm/_npx/7488/lib/node_modules/typescript-run/node_modules/esbuild/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall 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! /root/.npm/_logs/2021-07-18T10_11_30_207Z-debug.log
Install for [ 'typescript-run@latest' ] failed with code 1
what is the version of typescrint-run (you can run typescript-run --version)? can you also try npx typescript-run@latest ./otp.ts ?
I wanted to try typescript-run using npx only, it failed again.
OS: WSL Ubuntu 20.0,
npx typescript-run@latest src/index.ts
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '/root/.npm/_npx/3183/lib/node_modules/typescript-run/node_modules/esbuild/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall 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! /root/.npm/_logs/2021-07-19T10_39_14_046Z-debug.log
Install for [ 'typescript-run@latest' ] failed with code 1
Is it working when you globally install and run? not sure how to replicate this issue 🤔
Hey, Thanks for fast replies.
I am using npx binary runner so that, I don't have to install any npm modules (esbuild & ts-run) permanently on my machine, Neither globally nor in project.
Tried to reproduce the error again. You can also try in this Stackblitz Environment
with npx typescript-run src/index.ts
I tried the same in stackblitz
node -v 14.16.0 npm -v 7.17
Got this error.
& npm config get ignore-scripts was false
npx typescript-run src/index.ts
success Install finished in 2.7s
Error: esbuild: Failed to install correctly
Make sure you don't have "ignore-scripts" set to true. You can check this with
"npm config get ignore-scripts". If that returns true you can reset it back to
false using "npm config set ignore-scripts false" and then reinstall esbuild.
If you're using npm v7, make sure your package-lock.json file contains either
"lockfileVersion": 1 or the code "hasInstallScript": true. If it doesn't have
either of those, then it is likely the case that a known bug in npm v7 has
corrupted your package-lock.json file. Regenerating your package-lock.json file
should fix this issue.
at Object.eval (/home/.turbo/npx/D5z4qz/node_modules/esbuild/bin/esbuild:1:68)
at Object.function (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:174334)
at Module._compile (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:188593)
at Object.Module._extensions..js (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:188952)
at Module.load (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:187032)
at Function.Module._load (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:184610)
at Function.executeUserEntryPoint [as runMain] (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:701476)
at Object.a0_0x1b47 (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:1124489)
at _0x40163c (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:8:23879)
at _0x58cdae (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:45590)
(node:10) UnhandledPromiseRejectionWarning: Error: The service was stopped
at eval (/home/.turbo/npx/D5z4qz/node_modules/esbuild/lib/main.js:1215:25)
at eval (/home/.turbo/npx/D5z4qz/node_modules/esbuild/lib/main.js:609:9)
at Socket.afterClose (/home/.turbo/npx/D5z4qz/node_modules/esbuild/lib/main.js:587:7)
at Socket.EventEmitter.emit (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:126312)
at endReadableNT (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:6:489841)
at https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:125491
at https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:158166
at _0x31eff0 (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:158411)
at MessagePort._0xe4431a.port1.onmessage (https://aoniqbbzq--github.jw.staticblitz.com/blitz.84452ea99b8c6a79e19cae2129beaf85d5da007c.js:11:158524)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:10) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
So the issue you have on local is different from the one on stackblitz. I was aware of the one from stackblitz. it is due to incompatibility of stackblitz with few esbuild things.
It works on CodeSandbox - https://codesandbox.io/s/ts-compilation-0ucyu?file=/src/index.ts
From logs of your local run, it seems like there are some issues with postinstall script. Maybe some postinstall is getting skipped with npx in your machine. I wanted to see if it works with npm install -g typescript-run.
Yes It is working on codesandbox, don't why it's not working in machine.
npm i -g typescript-run@latest is also failing 😢
npm install -g typescript-run@latest
/root/.nvm/versions/node/v14.15.0/bin/ts-run -> /root/.nvm/versions/node/v14.15.0/lib/node_modules/typescript-run/src/index.js
/root/.nvm/versions/node/v14.15.0/bin/typescript-run -> /root/.nvm/versions/node/v14.15.0/lib/node_modules/typescript-run/src/index.js
> [email protected] postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/typescript-run/node_modules/esbuild
> node install.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '/root/.nvm/versions/node/v14.15.0/lib/node_modules/typescript-run/node_modules/esbuild/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/typescript-run/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall 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! /root/.npm/_logs/2021-07-21T09_46_43_929Z-debug.log
Not sure how to replicate this :(
Looks like the esbuild is not being installed properly and hence the install.js from esbuild is not there during postinstall 🤔