-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
.js
/ .mjs
/ .cjs
hidden files can not be imported
#42595
Comments
@nodejs/loaders |
It seems this is primarily because |
What is the use case for supporting a file named |
First, sorry for the late answer. I was making a static site generator with whose default behavior is just to copy the files as is to be served as is. I did not realize until testing that Node.js would not be able to import these "directory decorators", so i hade to switch to file names even more unusual that Node.js see as valid specifiers: Hope that helps anyway. |
It appears it has been fixed in Node.js 18.19.0 / 20.10.0 / 21.0.0, likely as part of the support for extensionless files added in #49974 . Thanks! |
Version
v17.8.0, v16.4.2
Platform
No response
Subsystem
esm
What steps will reproduce the bug?
Let's say we have the following files:
package.json
:index.js
:.js
/.mjs
/.cjs
:// nothing
Execute Node.js in the same directory with
node .
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
I think ".js", ".mjs" or ".cjs" should be imported and executed.
Even if this files might traditionally be considered hidden files on some systems and
path.extname(".js")
gives the empty string in Node.js, some people may consider these are not extensionless files, but rather files with an explicit extension but no basename.What do you see instead?
It produces the following error mesage:
In v17.8.0:
In v16.4.2:
Additional information
Setting directly
"main": ".js"
or"main": ".mjs"
in the package file also does not work, whereas setting"main": ".cjs"
actually executes it as a commonJS module anyway.The text was updated successfully, but these errors were encountered: