Skip to content

Dependency got cannot be browserified #8

@bafu

Description

@bafu

Description

To browserify Nit, we need to change a dependency or tweak the module design.

Reference: https://stackoverflow.com/questions/62492311/browserify-is-not-working-gives-undefined-process-versions-node

Steps to Reproduce

  1. Create a bundle

    $ browserify -o nit.min.js src/*
    
  2. Add the bundle in a HTML.

Expected Behavior

  1. Expected: Browser can include and execute the bundle successfully
  2. Actual: Bundle returns an error

Logs

Got the error in the browser console

Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at Object.<anonymous> (nit.min.js:39869:57)
    at Object.<anonymous> (nit.min.js:39992:4)
    at Object.225._process (nit.min.js:39992:17)
    at o (nit.min.js:1:265)
    at nit.min.js:1:316
    at Object.<anonymous> (nit.min.js:59362:22)
    at Object.<anonymous> (nit.min.js:60850:4)
    at Object.329.../as-promise/normalize-arguments (nit.min.js:60850:17)
    at o (nit.min.js:1:265)
    at nit.min.js:1:316

nit.min.js:39869:57

const nodejsMajorVersion = Number(process.versions.node.split('.')[0]);

Environment

  1. Nit: v1.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions