Skip to content

Webpack Error (webpack 5.0.16) #9

Open

Description

@kakha13

Error:

ERROR in ./node_modules/object-inspect/util.inspect.js 1:0-40
Module not found: Error: Can't resolve 'util' in 'C:\Apps\Any Book\node_modules\object-inspect'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

package.json

"dependencies": {
    "@nativescript-community/ui-webview": "^1.4.6",
    "@nativescript/core": "~8.5.7",
  },
  "devDependencies": {
    "@nativescript/android": "8.5.0",
    "@nativescript/webpack": "~5.0.16",
    "nativescript-vue-template-compiler": "~2.9.3"
  }

Activity

  1. minhson95th commented on Sep 28, 2023

    @minhson95th

    same issue

  2. sebj54 commented on Nov 29, 2023

    @sebj54
    Member

    It looks like I have a similar issue:

    See log
    ERROR in ./node_modules/object-inspect/util.inspect.js 1:0-40
    Module not found: Error: Can't resolve 'util' in '/Users/my-user/projects/my-project/node_modules/object-inspect'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
    	- install 'util'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "util": false }
    resolve 'util' in '/Users/my-user/projects/my-project/node_modules/object-inspect'
      Parsed request is a module
      using description file: /Users/my-user/projects/my-project/node_modules/object-inspect/package.json (relative path: .)
        resolve as module
          looking for modules in /Users/my-user/projects/my-project/node_modules
            single file module
              using description file: /Users/my-user/projects/my-project/package.json (relative path: ./node_modules/util)
                no extension
                  /Users/my-user/projects/my-project/node_modules/util doesn't exist
                .android.vue
                  /Users/my-user/projects/my-project/node_modules/util.android.vue doesn't exist
                .vue
                  /Users/my-user/projects/my-project/node_modules/util.vue doesn't exist
                .android.ts
                  /Users/my-user/projects/my-project/node_modules/util.android.ts doesn't exist
                .ts
                  /Users/my-user/projects/my-project/node_modules/util.ts doesn't exist
                .android.js
                  /Users/my-user/projects/my-project/node_modules/util.android.js doesn't exist
                .js
                  /Users/my-user/projects/my-project/node_modules/util.js doesn't exist
                .android.mjs
                  /Users/my-user/projects/my-project/node_modules/util.android.mjs doesn't exist
                .mjs
                  /Users/my-user/projects/my-project/node_modules/util.mjs doesn't exist
                .android.css
                  /Users/my-user/projects/my-project/node_modules/util.android.css doesn't exist
                .css
                  /Users/my-user/projects/my-project/node_modules/util.css doesn't exist
                .android.scss
                  /Users/my-user/projects/my-project/node_modules/util.android.scss doesn't exist
                .scss
                  /Users/my-user/projects/my-project/node_modules/util.scss doesn't exist
                .android.json
                  /Users/my-user/projects/my-project/node_modules/util.android.json doesn't exist
                .json
                  /Users/my-user/projects/my-project/node_modules/util.json doesn't exist
            /Users/my-user/projects/my-project/node_modules/util doesn't exist
          /Users/my-user/projects/my-project/node_modules/object-inspect/node_modules doesn't exist or is not a directory
          /Users/my-user/projects/my-project/node_modules/node_modules doesn't exist or is not a directory
          looking for modules in /Users/my-user/projects/my-project/node_modules
            single file module
              using description file: /Users/my-user/projects/my-project/package.json (relative path: ./node_modules/util)
                no extension
                  /Users/my-user/projects/my-project/node_modules/util doesn't exist
                .android.vue
                  /Users/my-user/projects/my-project/node_modules/util.android.vue doesn't exist
                .vue
                  /Users/my-user/projects/my-project/node_modules/util.vue doesn't exist
                .android.ts
                  /Users/my-user/projects/my-project/node_modules/util.android.ts doesn't exist
                .ts
                  /Users/my-user/projects/my-project/node_modules/util.ts doesn't exist
                .android.js
                  /Users/my-user/projects/my-project/node_modules/util.android.js doesn't exist
                .js
                  /Users/my-user/projects/my-project/node_modules/util.js doesn't exist
                .android.mjs
                  /Users/my-user/projects/my-project/node_modules/util.android.mjs doesn't exist
                .mjs
                  /Users/my-user/projects/my-project/node_modules/util.mjs doesn't exist
         Updating runtime package.json with configuration values...
    Project successfully prepared (android)
           .android.css
                  /Users/my-user/projects/my-project/node_modules/util.android.css doesn't exist
                .css
                  /Users/my-user/projects/my-project/node_modules/util.css doesn't exist
                .android.scss
                  /Users/my-user/projects/my-project/node_modules/util.android.scss doesn't exist
                .scss
                  /Users/my-user/projects/my-project/node_modules/util.scss doesn't exist
                .android.json
                  /Users/my-user/projects/my-project/node_modules/util.android.json doesn't exist
                .json
                  /Users/my-user/projects/my-project/node_modules/util.json doesn't exist
            /Users/my-user/projects/my-project/node_modules/util doesn't exist
          /Users/my-user/projects/node_modules doesn't exist or is not a directory
          /Users/my-user/node_modules doesn't exist or is not a directory
          /Users/node_modules doesn't exist or is not a directory
          /node_modules doesn't exist or is not a directory
     @ ./node_modules/object-inspect/index.js 68:18-43
     @ ./node_modules/side-channel/index.js 5:14-39
     @ ./node_modules/qs/lib/stringify.js 3:21-44
     @ ./node_modules/qs/lib/index.js 3:16-38
     @ ./node_modules/url/url.js 108:16-29
     @ ./node_modules/@nativescript-community/ui-webview/index.common.js 721:19-39
     @ ./node_modules/@nativescript-community/ui-webview/index.android.js 4:0-434 6:0-31 6:0-31 82:271-291 86:147-167 93:118-138 114:113-133 124:114-134 130:144-164 141:183-203 163:131-151 175:104-124 205:157-177 217:156-176 437:163-183 448:30-44 517:66-86 521:72-92 531:92-112 578:125-145 583:122-142 589:90-110 598:108-128 627:108-128 629:38-57 635:93-113 662:86-106 674:5-33 677:5-32 680:5-34 683:5-33 688:5-43 693:5-42 702:5-43 707:5-42 710:5-49 713:5-48 718:5-33 733:5-32 736:5-38 739:5-39 742:5-38 745:5-34 748:5-33 751:5-35 754:5-34 757:5-38 773:5-54 776:5-48 696:5-35
     @ ./node_modules/@nativescript-community/ui-webview/vue/index.js 3:46-69
     @ ./app/main.js 16:0-66 91:8-21
    
    webpack 5.89.0 compiled with 1 error in 6453 ms
    

    It is due to this method:

    public normalizeURL(url: string): string {
    if (!url || !this.normalizeUrls || url.startsWith(this.interceptScheme)) {
    return url;
    }
    try {
    return require('url').parse(url).format();
    } catch (error) {
    return url;
    }
    }

    I replaced the whole try-catch by return url and the error is now gone. @farfromrefug, what's your opinion on this? I could do the PR but I am not aware of any side-effect it might cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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