New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve module 'events' #363

Open
joetidee opened this Issue Mar 10, 2017 · 11 comments

Comments

6 participants
@joetidee

joetidee commented Mar 10, 2017

After requiring this package as per the instructions, I am getting:

Unable to resolve module 'events' from '/Users/myName/AwesomeProject/node_modules: Module does not exist in the module map ...

@Leonidas-from-XIV

This comment has been minimized.

Owner

Leonidas-from-XIV commented Mar 13, 2017

How did you install xml2js?

@i8wu

This comment has been minimized.

i8wu commented Mar 22, 2017

Just installed using npm, getting the same error.

Edit:
Resolved after npm install events and timers, but I think those two should be listed as dependencies for xml2js?

@sireneweb

This comment has been minimized.

sireneweb commented Apr 12, 2017

i have the same problem with angular2, i did this:

npm install @types/xml2js --save-dev
npm install xml2js --save-dev
npm install events --save-dev

then i can build, but i not tested if it'w work. Why i8wu you need timers ?

@i8wu

This comment has been minimized.

i8wu commented Apr 12, 2017

@sireneweb it came up as an unable to resolve module
npm install timers

@agersoncgps

This comment has been minimized.

agersoncgps commented Jul 28, 2017

I am getting this for every dependency, streams, buffers, timers...

@Leonidas-from-XIV

This comment has been minimized.

Owner

Leonidas-from-XIV commented Jul 28, 2017

@agersoncgps

This comment has been minimized.

agersoncgps commented Jul 28, 2017

Last login: Thu Jul 27 18:32:12 on ttys003
Adams-iMac-3:~ agerson$ cd /Users/agerson/Desktop/CGPSApp 
Adams-iMac-3:CGPSApp agerson$ npm install xml2js --save --loglevel verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'install',
npm verb cli   'xml2js',
npm verb cli   '--save',
npm verb cli   '--loglevel',
npm verb cli   'verbose' ]
npm info using npm@3.10.10
npm info using node@v6.11.1
npm verb request uri https://registry.npmjs.org/xml2js
npm verb request no auth needed
npm info attempt registry request try #1 at 8:32:14 PM
npm verb request id 05644741b37650bb
npm verb etag W/"5978142e-1ebbc"
npm verb lastModified Wed, 26 Jul 2017 04:01:50 GMT
npm http request GET https://registry.npmjs.org/xml2js
npm http 304 https://registry.npmjs.org/xml2js
npm verb headers { date: 'Fri, 28 Jul 2017 00:32:14 GMT',
npm verb headers   via: '1.1 varnish',
npm verb headers   'cache-control': 'max-age=300',
npm verb headers   etag: 'W/"5978142e-1ebbc"',
npm verb headers   age: '273',
npm verb headers   connection: 'keep-alive',
npm verb headers   'x-served-by': 'cache-jfk8134-JFK',
npm verb headers   'x-cache': 'HIT',
npm verb headers   'x-cache-hits': '4114',
npm verb headers   'x-timer': 'S1501201935.862040,VS0,VE0',
npm verb headers   vary: 'Accept-Encoding, Accept' }
npm verb etag https://registry.npmjs.org/xml2js from cache
npm verb get saving xml2js to /Users/agerson/.npm/registry.npmjs.org/xml2js/.cache.json
npm verb correctMkdir /Users/agerson/.npm correctMkdir not in flight; initializing
npm verb cache add spec xml2js@^0.4.17
npm verb addNamed ">=0.4.17 <0.5.0" is a valid semver range for xml2js
npm verb addNameRange registry:https://registry.npmjs.org/xml2js not in flight; fetching
npm verb get https://registry.npmjs.org/xml2js not expired, no request
npm verb addNamed "0.4.17" is a plain semver version for xml2js
npm verb afterAdd /Users/agerson/.npm/xml2js/0.4.17/package/package.json not in flight; writing
npm verb correctMkdir /Users/agerson/.npm correctMkdir not in flight; initializing
npm verb afterAdd /Users/agerson/.npm/xml2js/0.4.17/package/package.json written
npm verb request uri https://registry.npmjs.org/xmlbuilder
npm verb request no auth needed
npm info attempt registry request try #1 at 8:32:15 PM
npm verb etag W/"59526267-1563d"
npm verb lastModified Tue, 27 Jun 2017 13:49:27 GMT
npm http request GET https://registry.npmjs.org/xmlbuilder
npm http 304 https://registry.npmjs.org/xmlbuilder
npm verb headers { date: 'Fri, 28 Jul 2017 00:32:15 GMT',
npm verb headers   via: '1.1 varnish',
npm verb headers   'cache-control': 'max-age=300',
npm verb headers   etag: 'W/"59526267-1563d"',
npm verb headers   age: '62',
npm verb headers   connection: 'keep-alive',
npm verb headers   'x-served-by': 'cache-jfk8134-JFK',
npm verb headers   'x-cache': 'HIT',
npm verb headers   'x-cache-hits': '1',
npm verb headers   'x-timer': 'S1501201936.700066,VS0,VE0',
npm verb headers   vary: 'Accept-Encoding, Accept' }
npm verb etag https://registry.npmjs.org/xmlbuilder from cache
npm verb get saving xmlbuilder to /Users/agerson/.npm/registry.npmjs.org/xmlbuilder/.cache.json
npm verb correctMkdir /Users/agerson/.npm correctMkdir not in flight; initializing
npm verb cache add spec xmlbuilder@^4.1.0
npm verb addNamed ">=4.1.0 <5.0.0" is a valid semver range for xmlbuilder
npm verb addNameRange registry:https://registry.npmjs.org/xmlbuilder not in flight; fetching
npm verb get https://registry.npmjs.org/xmlbuilder not expired, no request
npm verb addNamed "4.2.1" is a plain semver version for xmlbuilder
npm verb afterAdd /Users/agerson/.npm/xmlbuilder/4.2.1/package/package.json not in flight; writing
npm verb correctMkdir /Users/agerson/.npm correctMkdir not in flight; initializing
npm verb afterAdd /Users/agerson/.npm/xmlbuilder/4.2.1/package/package.json written
npm verb correctMkdir /Users/agerson/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /Users/agerson/.npm/_locks/staging-3d17163a40924b46.lock for /Users/agerson/Desktop/CGPSApp/node_modules/.staging
npm verb unbuild node_modules/.staging/xml2js-c5f46ee4
npm verb gentlyRm don't care about contents; nuking /Users/agerson/Desktop/CGPSApp/node_modules/.staging/xml2js-c5f46ee4
npm verb tar unpack /Users/agerson/.npm/xml2js/0.4.17/package.tgz
npm verb tar unpacking to /Users/agerson/Desktop/CGPSApp/node_modules/.staging/xml2js-c5f46ee4
npm verb gentlyRm don't care about contents; nuking /Users/agerson/Desktop/CGPSApp/node_modules/.staging/xml2js-c5f46ee4
npm verb gentlyRm don't care about contents; nuking /Users/agerson/Desktop/CGPSApp/node_modules/.staging/xml2js-c5f46ee4/node_modules
npm info lifecycle xml2js@0.4.17~preinstall: xml2js@0.4.17
npm verb unbuild node_modules/xml2js
npm info lifecycle xml2js@0.4.17~preuninstall: xml2js@0.4.17
npm info lifecycle xml2js@0.4.17~uninstall: xml2js@0.4.17
npm verb unbuild rmStuff xml2js@0.4.17 from /Users/agerson/Desktop/CGPSApp/node_modules
npm info lifecycle xml2js@0.4.17~postuninstall: xml2js@0.4.17
npm verb gentlyRm don't care about contents; nuking /Users/agerson/Desktop/CGPSApp/node_modules/xml2js
npm info linkStuff xml2js@0.4.17
npm verb linkBins xml2js@0.4.17
npm verb linkMans xml2js@0.4.17
npm info lifecycle xml2js@0.4.17~install: xml2js@0.4.17
npm info lifecycle xml2js@0.4.17~postinstall: xml2js@0.4.17
npm verb unlock done using /Users/agerson/.npm/_locks/staging-3d17163a40924b46.lock for /Users/agerson/Desktop/CGPSApp/node_modules/.staging
npm verb saving [ { name: 'xml2js', spec: '^0.4.17', save: 'dependencies' } ]
CGPSApp@0.0.1 /Users/agerson/Desktop/CGPSApp
├── UNMET PEER DEPENDENCY react-native-vector-icons@4.2.0
└── xml2js@0.4.17 

npm WARN @shoutem/animation@0.8.10 requires a peer of react@^15.0.0 but none was installed.
npm verb 
npm verb If you need help, you may report this error at:
npm verb     <https://github.com/npm/npm/issues>
npm WARN native-base@2.3.0 requires a peer of react-native-vector-icons@~4.1.1 but none was installed.
npm verb 
npm verb If you need help, you may report this error at:
npm verb     <https://github.com/npm/npm/issues>
npm verb exit [ 0, true ]
npm info ok 
Adams-iMac-3:CGPSApp agerson$ 

screenshot 2017-07-27 20 29 14

@Leonidas-from-XIV

This comment has been minimized.

Owner

Leonidas-from-XIV commented Jul 28, 2017

@agersoncgps

This comment has been minimized.

agersoncgps commented Jul 28, 2017

Its built entirely on top of Node. What makes you question it?

@Leonidas-from-XIV

This comment has been minimized.

Owner

Leonidas-from-XIV commented Jul 28, 2017

@johndous

This comment has been minimized.

johndous commented Jul 30, 2017

I also tried to use the xml2js in a my react-native app and I had similar issues. The solution was to install all required xml2js dependencies in my react-native app.

cd myReactNativeApp
npm install events buffer stream timers --save

Index.js

import React from 'react'
import { View } from 'react-native';
import ExportSvg from './ExportSvg';

const source = `<svg xmlns='http://www.w3.org/2000/svg' width='420' height='420' style='background-color:rgba(240,240,240,1);'>
  <g style='fill:rgba(38,145,217,1); stroke:rgba(38,145,217,1); stroke-width:2.1;'>
    <rect  x='185' y='185' width='50' height='50'/>
    <rect  x='185' y='235' width='50' height='50'/>
    <rect  x='185' y='285' width='50' height='50'/>
    <rect  x='135' y='85' width='50' height='50'/>
    <rect  x='235' y='85' width='50' height='50'/>
    <rect  x='135' y='185' width='50' height='50'/>
    <rect  x='235' y='185' width='50' height='50'/>
    <rect  x='135' y='235' width='50' height='50'/>
    <rect  x='235' y='235' width='50' height='50'/>
    <rect  x='85' y='235' width='50' height='50'/>
    <rect  x='285' y='235' width='50' height='50'/>
    <rect  x='85' y='285' width='50' height='50'/>
    <rect  x='285' y='285' width='50' height='50'/>
  </g>
</svg>`;

export default (props) => (
  <View style={{flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: 'powderblue'}} >
    <ExportSvg
      source={source}
    />
  </View>
);

ExportSvg.js

import React from 'react';
import { View, Text } from 'react-native'
import { parseString } from 'xml2js';

class ExportSvg extends React.Component {
  constructor(props) {
    super(props);
    this.state = { svg: <Text>SVG</Text> };
  }

  renderSvg(source){
    parseString(source, (err, result) => {
      if (err) {
        this.setState({ svg: <Text>Error parsing xml.</Text>});
        return;
      }
      this.setState({ svg: <Text>{JSON.stringify(result)}</Text>});
    });
  }

  render(){
    const { source } = this.props;
    return (
      <View>
        {this.state.svg}
        {this.renderSvg(source)}
      </View>
    );
  }
}

export default ExportSvg;

screen shot 2017-07-31 at 01 43 30

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