docker-node
docker-node copied to clipboard
Yarn build fails with new node:12-alpine
It works with old node@sha256:6b5b783c9cfe229af0bd5b0b677dd32005bb22d58465f3d0fe7fbd1c60ce068c
Does not work with latest (node:12-alpine) node@sha256:7a6d3e124142fe56b974d5beccf42180f9e217d509a02801838801fc85a15c35
package.json
...
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
}
...
yarn.lock
...
"@babel/core@>=7.2.2", "@babel/core@^7.1.0", "@babel/core@^7.7.5", "@babel/core@^7.8.4":
version "7.8.6"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.8.6.tgz#27d7df9258a45c2e686b6f18b6c659e563aa4636"
"@babel/preset-env@^7.8.4":
version "7.8.6"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.8.6.tgz#2a0773b08589ecba4995fc71b1965e4f531af40b"
"@babel/preset-react@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.8.3.tgz#23dc63f1b5b0751283e04252e78cf1d6589273d2"
...
yarn run v1.22.4
$ webpack --config config/webpack.config.js
Hash: f440ef2592f07f2d64ca
Version: webpack 4.42.0
Time: 681ms
Built at: 05/28/2020 10:45:28 AM
1 asset
Entrypoint main = main.e2aa62e6c9c0a3dfdc36.js
[0] ./src/index.js 4.9 KiB {0} [built] [failed] [1 error]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@babel/compat-data/corejs3-shipped-proposals'
Require stack:
- /opt/atlassian/pipelines/agent/build/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
- /opt/atlassian/pipelines/agent/build/node_modules/@babel/preset-env/lib/index.js
- /opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/files/plugins.js
- /opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/files/index.js
- /opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/index.js
- /opt/atlassian/pipelines/agent/build/node_modules/babel-loader/lib/index.js
- /opt/atlassian/pipelines/agent/build/node_modules/loader-runner/lib/loadLoader.js
- /opt/atlassian/pipelines/agent/build/node_modules/loader-runner/lib/LoaderRunner.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/NormalModule.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/NormalModuleFactory.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/Compiler.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack/lib/webpack.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/bin/utils/validate-options.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/bin/utils/convert-argv.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/bin/cli.js
- /opt/atlassian/pipelines/agent/build/node_modules/webpack/bin/webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (/opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js:10:55)
at Module._compile (/opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (/opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/@babel/preset-env/lib/index.js:29:44)
at Module._compile (/opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (/opt/atlassian/pipelines/agent/build/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at requireModule (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/files/plugins.js:165:12)
at loadPreset (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/files/plugins.js:83:17)
at createDescriptor (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
at /opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
at Array.map (<anonymous>)
at createDescriptors (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
at createPresetDescriptors (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
at presets (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
at mergeChainOpts (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-chain.js:320:26)
at /opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-chain.js:283:7
at Generator.next (<anonymous>)
at buildRootChain (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/config-chain.js:120:29)
at buildRootChain.next (<anonymous>)
at loadPrivatePartialConfig (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/partial.js:95:62)
at loadPrivatePartialConfig.next (<anonymous>)
at Function.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/@babel/core/lib/config/partial.js:120:25)
at Generator.next (<anonymous>)
at evaluateSync (/opt/atlassian/pipelines/agent/build/node_modules/gensync/index.js:244:28)
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 460 bytes {0} [built]
[2] (webpack)/buildin/global.js 472 bytes {0} [built]
[3] (webpack)/buildin/module.js 497 bytes {0} [built]
+ 1 hidden module
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.```
Same issue here... Workaround: changed from to node:12.16.3-alpine The only change in Dockerfile is NODE_VERSION soo the problem is the node version (12.17.0) or build
Is it possible that you are setting NODE_ENV=production
in your CI / build environment? I arrived here with a similar issue of missing packages for no apparent reason, and adding NODE_ENV=production
to my environment variables ended up being the cause. I explicitly added --production=false
to my yarn install
to avoid it in the future.
https://classic.yarnpkg.com/en/docs/cli/install/#toc-yarn-install-production-true-false
Yarn will not install any package listed in devDependencies if the NODE_ENV environment variable is set to production. Use this flag to instruct Yarn to ignore NODE_ENV and take its production-or-not status from this flag instead.
This issue looks to be because @babel/preset-env is on version 7.8.4. There is a fix for this in 7.9.0. Rolling back to node:12.16.3-alpine worked for us as well. https://github.com/nodejs/node/issues/32852
Is it possible that you are setting
NODE_ENV=production
in your CI / build environment? I arrived here with a similar issue of missing packages for no apparent reason, and addingNODE_ENV=production
to my environment variables ended up being the cause. I explicitly added--production=false
to myyarn install
to avoid it in the future.https://classic.yarnpkg.com/en/docs/cli/install/#toc-yarn-install-production-true-false
Yarn will not install any package listed in devDependencies if the NODE_ENV environment variable is set to production. Use this flag to instruct Yarn to ignore NODE_ENV and take its production-or-not status from this flag instead.
This happens for me in the bitbucket pipeline. In the first step I install dependencies and in the second step the build is executed. The dependencies/node_modules are there. The error:
Cannot find module '@babel/compat-data/corejs3-shipped-proposals'
is missleading.