Skip to content

Conversation

@xnv
Copy link
Member

@xnvxnv commented Feb 13, 2025

掲題どおり。

ESM になっているモジュールにおいて、bin/run のように拡張子のないファイルは、ある時期までの Node.js で (デフォルトでは) サポートされていない ようです 。具体的には v18.19.0 未満の v18 系や、v20.10.0 未満の v20 系が該当する とのこと

$ ./node_modules/.bin/akashic-cli-sandbox node:internal/errors:490 ErrorCaptureStackTrace(err); ^ TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /(...snip...)/node_modules/@akashic/akashic-cli-sandbox/bin/akashic-cli-sandbox. Loading extensionless files is not supported inside of "type":"module" package.json contexts. The package.json file /(...snip...)/node_modules/@akashic/akashic-cli-sandbox/package.json caused this "type":"module" context. Try changing /(...snip...)/node_modules/@akashic/akashic-cli-sandbox/bin/akashic-cli-sandbox to have a file extension. Note the "bin" field of package.json can point to a file with an extension, for example{"type":"module","bin":{"akashic-cli-sandbox":"./bin/akashic-cli-sandbox.js"}} at new NodeError (node:internal/errors:399:5) at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11) at defaultGetFormat (node:internal/modules/esm/get_format:121:38) at defaultLoad (node:internal/modules/esm/load:81:20) at nextLoad (node:internal/modules/esm/loader:163:28) at ESMLoader.load (node:internal/modules/esm/loader:605:26) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22) at new ModuleJob (node:internal/modules/esm/module_job:64:26) at #createModuleJob (node:internal/modules/esm/loader:480:17) at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34){code: 'ERR_UNKNOWN_FILE_EXTENSION' } 

EOL が近い v18 はまだしも v20 でトラブルになるのは避けたく、エラーメッセージのとおり拡張子を追加します。

package.json の bin 指定の問題なので、ユニットテストや test/e2e.js の --local では動作確認できません。Mac 上の Node 18.16.0 で sandbox, export などいくつか npm pack する限りでは問題ないので、prerelease で publish したもので動作確認します。

"scripts":{
"prepublish": "npm run build",
"start": "npm run build && node bin/run",
"start": "npm run build && node bin/akashic-cli-sandbox.js",
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

別件: 元々パスがおかしかったようなので修正。(sandbox で npm start することはなさそうなので、削除してしまっても良さそうですが)

"scripts":{
"prepublish": "npm run clean && npm run build",
"clean": "rimraf ./lib && rimraf ./spec/build",
"start": "npm run build && node bin/run",
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

別件2: 元々なかったファイルを指していました。extra 自体に start はありえないので削除。

@xnvxnv merged commit 662a0b0 into mainFeb 14, 2025
9 checks passed
@xnvxnv deleted the fix-bin-ext branch February 14, 2025 07:02
@github-actionsgithub-actionsbot mentioned this pull request Feb 14, 2025
@github-actionsgithub-actionsbot mentioned this pull request Apr 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@xnv@yu-ogi@ShinobuTakahashi