Skip to content

Module not found Error when using dgram in an Electron App #1023

@ThomasLochbrunner

Description

@ThomasLochbrunner
  • Node.js Version: 8.9.3
  • OS: macOS 10.12.6
  • Scope: Code
  • Module: dgram@1.0.1

Hi,

I am trying to port a former Cordova App based on AngularJS to an Electron Desktop App. So far I already replaced most of the Cordova Plugins with Node Modules, but I am struggeling with the last one - dgram.
I tried to import / require the module within my Code either by

var dgram = require("dgram")

or

import * as dgram from "dgram"

But when running npm start I always get the following error stacktrace telling me that the Module dgram could not be found:

ERROR in ./src/app/services/sensor.service.ts
Module not found: Error: Can't resolve 'dgram' in '/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/app/services'
resolve 'dgram' in '/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/app/services'
  Parsed request is a module
  using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src/app/services)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src/app/services)
    resolve as module
      /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/app/services/node_modules doesn't exist or is not a directory
      /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/app/node_modules doesn't exist or is not a directory
      /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/node_modules doesn't exist or is not a directory
      /Users/thomaslochbrunner/Development/TestPlayground/node_modules doesn't exist or is not a directory
      /Users/thomaslochbrunner/Development/node_modules doesn't exist or is not a directory
      /Users/thomaslochbrunner/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
      looking for modules in /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules
        using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./node_modules)
          using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./node_modules/dgram)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.js doesn't exist
            as directory
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram doesn't exist
      looking for modules in /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules
        using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./node_modules)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./node_modules)
          using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./node_modules/dgram)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.js doesn't exist
            as directory
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram doesn't exist
      looking for modules in /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src
        using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src)
          using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src/dgram)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.js doesn't exist
            as directory
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram doesn't exist
      looking for modules in /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src
        using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src)
          Field 'browser' doesn't contain a valid alias configuration
        after using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src)
          using description file: /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/package.json (relative path: ./src/dgram)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.ts doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.js doesn't exist
            as directory
              /Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram doesn't exist
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/app/services/node_modules]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/app/node_modules]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/node_modules]
[/Users/thomaslochbrunner/Development/TestPlayground/node_modules]
[/Users/thomaslochbrunner/Development/node_modules]
[/Users/thomaslochbrunner/node_modules]
[/Users/node_modules]
[/node_modules]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.ts]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.js]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.ts]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram.js]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/node_modules/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.ts]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.js]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.ts]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram.js]
[/Users/thomaslochbrunner/Development/TestPlayground/ElectronTestApp/src/dgram]
 @ ./src/app/services/sensor.service.ts 17:0-31
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts

I already tried to manually install dgram by running

npm install dgram

and also copied the dgram.js-File from the lib Folder from the Node-GitHub Repo into the node_modules/dgram Folder - but without any success.

As far as I understand it should be possible to use the dgram Module in an Electron App and in order to use it you do not need to manually install the dgram-Module, as it is built in to NodeJS.
But for some reason it is not working in my current Project.

Do you have any advise on how to get this to work?

Thank you in advance and best regards,
Thomas

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