简体   繁体   中英

Including a custom node module in react.js project causing “Uncaught Type Error : exists is not a function”

I have a react.js project in which I would like to use a custom node module which is a private repository in github. I include the module in package.json as follows

{
  "name": "react-app",
  "version": "0.0.0",
  "dependencies": {
    "custom-module": "git+https://<oauthtoken>:x-oauth-basic@github.com/myname/custom-module"
  }
}

When I do npm install and do the following in one of the models in my react app

var customModule = require('custom-module');

and load the app in the browser, I am getting the following error browser console

Uncaught TypeError: exists is not a function
  package.discover @ (index):110233
  package @ (index):110207420
  ../lib/dir @ (index):109791

Why am I getting this error?

NOTE: The same custom module is working fine in a server side node.js application.

What are the contents of package.json? Are you sure you have used --save when using npm install?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM