@babel/register write cache fail in node:alpine docker container
See original GitHub issueBug Report
- I would like to work on a fix!
Current Behavior
In node:alpine
docker image. The folder node_modules
create by root. And node server runs by ‘node’ user. So node_modules
isn’t writeable.
cache.js
not handle ENOENT
error. It just throw out and crash node server.
/home/node/app/node_modules/@babel/register/lib/cache.js:80
throw e;
^
Error: ENOENT: no such file or directory, mkdir '/home/node/app/node_modules/.cache/@babel/register'
at Object.mkdirSync (fs.js:856:3)
at module.exports.sync (/home/node/app/node_modules/make-dir/index.js:97:6)
at save (/home/node/app/node_modules/@babel/register/lib/cache.js:61:23)
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
errno: -2,
syscall: 'mkdir',
code: 'ENOENT',
path: '/home/node/app/node_modules/.cache/@babel/register'
}
Input Code
- REPL or Repo link if applicable:
var your => (code) => here;
Expected behavior/code A clear and concise description of what you expected to happen (or code).
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- Filename:
babel.config.js
{
"your": { "config": "here" }
}
Environment
- Babel version(s): v7.8.3
- Node/npm version: Node v13.8.0/npm 6.13.6
- OS: Alpine Linux
- Monorepo: no
- How you are using Babel:
register
Possible Solution
Additional context/Screenshots Add any other context about the problem here. If applicable, add screenshots to help explain.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Node and docker - how to handle babel or typescript build?
I'm not so familiar with typescript, but here's an example implementation using yarn and babel. Using this Dockerfile, we can build a development...
Read more >Node.js Docker workflow - Guillaume Jacquart - Medium
Docker compose is a tool by Docker which allows you to define your whole application stack (app services, databases, cache layer, …) as...
Read more >Optimizing builds with cache management
Understanding Docker's build cache helps you write better Dockerfiles that result in faster builds. Have a look at the following example, which shows...
Read more >Docker build fails with nonsensical EPERM: operation not ...
I have a circleci build that's failing when it tries to build a Docker image. Specifically it fails when it tries to execute...
Read more >Docker build not using cache - GitLab Forum
I am trying to speed up my Docker build by using the --cache-from option. This works on my local machine but not on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As a workaround, you can disable the register cache via
BABEL_DISABLE_CACHE
envIf
node_modules
is not writable due to permission errors, it should throwEACCESS
instead ofENOENT
. Babel will ignore theEACCESS
error and produce warnings only.Per http://man7.org/linux/man-pages/man3/errno.3.html
In your case, maybe
/home/node/app/node_modules
is a dangling symbolic link mounted by Docker. @cncolder Can you share the reproducing Dockerfile?@cncolder Thanks for the reproduction Dockerfile.
I can confirm this issue can be reproduced and thus I have filed one to themake-dir
repo: https://github.com/sindresorhus/make-dir/issues/25make-dir
is used inbabel-register
to create cache directory. Note that this issue does not affect Babel 8, wheremake-dir
has been replaced by native recursivefs.mkdir
supported onnode>=10.12
.It seems that
fs.mkdir
will throwsENOENT
on the following cases andmake-dir
aligns to its behaviour.It has been fixed recently on Node.js: (issue: https://github.com/nodejs/node/issues/31481)
Before we dropped node.js <= 13 support, we should workaround this node bug.