0

I have cloned 5 months old projects from GitHub, currently, I am using Nodejs 18+ version.

I have tried:

npx install cross-env

//tried to install and want to add below code into pakage.json

"dev": "cross-env NODE_OPTIONS='--openssl-legacy-provider' next dev",

tried to install this code but got error I get those solutions from StackOverFlow but this code is not working in my case.

Error
(base) Apples-MBP:nextjs-one apple$ npx install cross-env
npm ERR! could not determine executable to run

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/apple/.npm/_logs/2022-05-20T14_50_41_825Z-debug-0.log
(base) Apples-MBP:nextjs-one apple$ npx install cross-env
npm ERR! could not determine executable to run

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/apple/.npm/_logs/2022-05-20T14_53_13_994Z-debug-0.log
(base) Apples-MBP:nextjs-one apple$ npm run dev

this error occurred while npm run dev

(base) Apples-MBP:nextjs-one apple$ npm run dev

> client-code@0.1.0 dev
> next dev

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at OriginalSource.updateHash (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack-sources3/index.js:1:10264)
    at NormalModule._initBuildHash (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68468:17)
    at handleParseResult (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68534:10)
    at /Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68628:4
    at processResult (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68343:11)
    at /Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68407:5
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at OriginalSource.updateHash (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack-sources3/index.js:1:10264)
    at NormalModule._initBuildHash (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68468:17)
    at handleParseResult (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68534:10)
    at /Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68628:4
    at processResult (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68343:11)
    at /Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68407:5
node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:133:10)
    at BulkUpdateDecorator.hashFactory (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:138971:18)
    at BulkUpdateDecorator.update (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:138872:50)
    at OriginalSource.updateHash (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack-sources3/index.js:1:10264)
    at NormalModule._initBuildHash (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68468:17)
    at handleParseResult (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68534:10)
    at /Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68628:4
    at processResult (/Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68343:11)
    at /Users/apple/Desktop/projects/karshak/nextjs-one/node_modules/next/dist/compiled/webpack/bundle5.js:68407:5 {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Node.js v18.1.0

please provide me with the best solution for it.

anilraj
  • 39
  • 1
  • 5

1 Answers1

0

npx is used to run programs from NPM. You're trying to execute the install package but it doesn't come with an executable as it isn't designed to be run as a stand along application (unlike, for example, create-react-app.

To install a program as a dependency for use in your build scripts you need to use npm.

npm install --save-dev cross-env

See also Difference between npx and npm?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • thanks, Quentin its works for me. I need a favor, actually, I am not able to understand those types of errors easily. What would I need to do to creak these types of errors easily in React, Next, or Node Js development? – anilraj May 20 '22 at 18:14