Category: Node.js

  • Install Yarn Package Manager

    Install Yarn Package Manager

    Yarn is a package manager for JavaScript like npm. It is commonly used for managing dependencies for Node.js applications, but it can also be used for front-end development with frameworks like Rmeact, Angular, and Vue.js.

    To install the Yarn package manager on ubuntu, run:

    curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
    echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    sudo apt-get update && sudo apt-get install yarn
    

    Back to Node.js

  • gridsome error:03000086:digital envelope routines::initialization error

    gridsome error:03000086:digital envelope routines::initialization error

    When starting a gridsome project on Ubuntu 20.04 with Node.js version v18.10.0, it failed with the error message “error:03000086:digital envelope routines::initialization error”.

    boby@sok-01:~/www/learn/gridsome/my-gridsome-site$ gridsome develop
    Gridsome v0.7.23
    
    Initializing plugins...
    Load sources - 0s
    Create GraphQL schema - 0.03s
    Create pages and templates - 0.03s
    Generate temporary code - 0.03s
    Bootstrap finish - 0.56s
    10% building 1/1 modules 0 activeError: error:0308010C:digital envelope routines::unsupported
        at new Hash (node:internal/crypto/hash:71:19)
        at Object.createHash (node:crypto:133:10)
        at module.exports (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/util/createHash.js:135:53)
        at NormalModule._initBuildHash (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:417:16)
        at handleParseError (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:471:10)
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:503:5
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:358:12
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:373:3
        at iterateNormalLoaders (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
        at iterateNormalLoaders (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:236:3
        at runSyncOrAsync (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
        at iterateNormalLoaders (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
        at Array. (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
        at Storage.finished (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
    10% building 1/3 modules 2 active /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/hot/dev-server.jsnode:internal/crypto/hash:71
      this[kHandle] = new _Hash(algorithm, xofLen);
                      ^
    
    Error: error:0308010C:digital envelope routines::unsupported
        at new Hash (node:internal/crypto/hash:71:19)
        at Object.createHash (node:crypto:133:10)
        at module.exports (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/util/createHash.js:135:53)
        at NormalModule._initBuildHash (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:417:16)
        at handleParseError (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:471:10)
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:503:5
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/webpack/lib/NormalModule.js:358:12
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:373:3
        at iterateNormalLoaders (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
        at Array. (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
        at Storage.finished (/mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
        at /mnt/data/sites/learn/gridsome/my-gridsome-site/node_modules/graceful-fs/graceful-fs.js:123:16
        at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
      opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
      library: 'digital envelope routines',
      reason: 'unsupported',
      code: 'ERR_OSSL_EVP_UNSUPPORTED'
    }
    
    Node.js v18.10.0
    boby@sok-01:~/www/learn/gridsome/my-gridsome-site$ 
    

    To fix the error, use the command

    NODE_OPTIONS='--openssl-legacy-provider' gridsome develop
    

    To make it permanent, you can edit the package.json file in the root directory of your gridsome project

    Find

        "develop": "gridsome develop",
    

    Replace with

        "develop": "NODE_OPTIONS='--openssl-legacy-provider' gridsome develop",
    

    Now use

    yarn develop
    

    Or

    npm run develop
    

    Instead of the “gridsome develop” command.

    Back to Node.js

  • How to Install Yarn Package Manager on Ubuntu

    How to Install Yarn Package Manager on Ubuntu

    Yarn is a javascript package manager like npm.

    Import the GPG key

    curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
    

    Add the repository

    echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
    

    Instal yrarn with apt

    sudo apt-get update && sudo apt-get install yarn
    

    See Node.js