IM trying to build Docker image for my simple todo application which I have built-in react and JS but when I'm building my application getting ERROR on [4/4] RUN npm run build
this is the error I'm getting
=> ERROR [4/4] RUN npm run build 4.4s
------
> [4/4] RUN npm run build:
#8 1.648
#8 1.648 > todo-app@0.1.0 build
#8 1.648 > react-scripts build
#8 1.648
#8 3.318 Creating an optimized production build...
#8 3.815 Error: error:0308010C:digital envelope routines::unsupported
#8 3.815 at new Hash (node:internal/crypto/hash:67:19)
#8 3.815 at Object.createHash (node:crypto:130:10)
#8 3.815 at module.exports (/todo-app/node_modules/webpack/lib/util/createHash.js:135:53)
#8 3.815 at NormalModule._initBuildHash (/todo-app/node_modules/webpack/lib/NormalModule.js:417:16)
#8 3.815 at handleParseError (/todo-app/node_modules/webpack/lib/NormalModule.js:471:10)
#8 3.815 at /todo-app/node_modules/webpack/lib/NormalModule.js:503:5
#8 3.815 at /todo-app/node_modules/webpack/lib/NormalModule.js:358:12
#8 3.815 at /todo-app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
#8 3.815 at iterateNormalLoaders (/todo-app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
#8 3.815 at iterateNormalLoaders (/todo-app/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
#8 3.815 at /todo-app/node_modules/loader-runner/lib/LoaderRunner.js:236:3
#8 3.815 at runSyncOrAsync (/todo-app/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
#8 3.815 at iterateNormalLoaders (/todo-app/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
#8 3.815 at Array.<anonymous> (/todo-app/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
#8 3.815 at Storage.finished (/todo-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
#8 3.815 at /todo-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
#8 3.831 /todo-app/node_modules/react-scripts/scripts/build.js:19
#8 3.831 throw err;
#8 3.831 ^
#8 3.831
#8 3.831 Error: error:0308010C:digital envelope routines::unsupported
#8 3.831 at new Hash (node:internal/crypto/hash:67:19)
#8 3.831 at Object.createHash (node:crypto:130:10)
#8 3.831 at module.exports (/todo-app/node_modules/webpack/lib/util/createHash.js:135:53)
#8 3.831 at NormalModule._initBuildHash (/todo-app/node_modules/webpack/lib/NormalModule.js:417:16)
#8 3.831 at /todo-app/node_modules/webpack/lib/NormalModule.js:452:10
#8 3.831 at /todo-app/node_modules/webpack/lib/NormalModule.js:323:13
#8 3.831 at /todo-app/node_modules/loader-runner/lib/LoaderRunner.js:367:11
#8 3.831 at /todo-app/node_modules/loader-runner/lib/LoaderRunner.js:233:18
#8 3.831 at context.callback (/todo-app/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
#8 3.831 at /todo-app/node_modules/babel-loader/lib/index.js:59:103 {
#8 3.831 opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
#8 3.831 library: 'digital envelope routines',
#8 3.831 reason: 'unsupported',
#8 3.831 code: 'ERR_OSSL_EVP_UNSUPPORTED'
#8 3.831 }
#8 3.831
#8 3.831 Node.js v17.1.0
#8 3.842 npm notice
#8 3.842 npm notice New patch version of npm available! 8.1.2 -> 8.1.4
#8 3.842 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.1.4>
#8 3.842 npm notice Run `npm install -g [email protected]` to update!
#8 3.843 npm notice
------
executor failed running [/bin/sh -c npm run build]: exit code: 1
and this is my Dockerfile
FROM node:17.1-alpine
WORKDIR /todo-app
ENV PATH=".node_modules/.bin:$PATH"
COPY . .
RUN npm run build
CMD ["npm", "start"]
CodePudding user response:
In my case this error is usually because of node v17 vs. webpack which usually works fine with node v16.
Did you try Node in version 16 (it is LTS)?
CodePudding user response:
Can you try to downgrade your node version?
Please refer : https://exerror.com/error-error0308010cdigital-envelope-routinesunsupported-in-reactjs/

