/usr/bin/env: ‘node\r’: No such file or directory
Closed this issue · 0 comments
milahu commented
the \r\n
line ends break the binary on linux
this only appears when i install with yarn (yarn@1)
cd $(mktemp -d)
yarn init -y
yarn add ts-to-jsdoc
jq -r .version node_modules/ts-to-jsdoc/package.json
# 1.1.2
npx ts-to-jsdoc
# /usr/bin/env: ‘node\r’: No such file or directory
# /usr/bin/env: use -[v]S to pass options in shebang lines
hexdump -C node_modules/.bin/ts-to-jsdoc | head -n2
# 00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 6e |#!/usr/bin/env n|
# 00000010 6f 64 65 0d 0a 22 75 73 65 20 73 74 72 69 63 74 |ode.."use strict|
printf '\r\n' | hexdump -C
# 00000000 0d 0a |..|
# 00000002
wget https://registry.yarnpkg.com/ts-to-jsdoc/-/ts-to-jsdoc-1.1.2.tgz
tar xf ts-to-jsdoc-1.1.2.tgz
hexdump -C package/bin/ts-to-jsdoc | head -n2
# 00000000 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 6e |#!/usr/bin/env n|
# 00000010 6f 64 65 0d 0a 22 75 73 65 20 73 74 72 69 63 74 |ode.."use strict|
wget https://registry.npmjs.com/ts-to-jsdoc/-/ts-to-jsdoc-1.1.2.tgz
# same
workaround
node node_modules/.bin/ts-to-jsdoc
the \r
is not in the source code,
so i guess you edited the bin/ts-to-jsdoc
file manually before publish
fix: add a build script tsc --build
which runs on npm publish
next error
npx ts-to-jsdoc -o src-jsdoc src/
# Error: Cannot find module '../index'
fix
sed -i 's,"../index","ts-to-jsdoc/index.js",' node_modules/.bin/ts-to-jsdoc
next error
npx ts-to-jsdoc -o src-jsdoc/ src/
# [ERROR] Output directory /tmp/src-jsdoc does not exist.
workaround
mkdir src-jsdoc