Skip to content
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

Browserify or Node: Error: Cannot find module 'tether' #70

Closed
kimmobrunfeldt opened this issue Feb 17, 2015 · 8 comments
Closed

Browserify or Node: Error: Cannot find module 'tether' #70

kimmobrunfeldt opened this issue Feb 17, 2015 · 8 comments

Comments

@kimmobrunfeldt
Copy link

Trying to var Tether = require('tether'); and build with browserify, produces this error: Error: Cannot find module 'tether'

In node_modules/tether/package.json, there is no "main" key which would indicate where to look for a file. This is why browserify/node can't find any file matching name "tether"

Here is the most minimal setup to reproduce the problem: https://github.com/kimmobrunfeldt/tether-browserify-bug

@kimmobrunfeldt
Copy link
Author

Related to #68

@davekiss
Copy link

davekiss commented Jun 3, 2015

Getting this same error here too, but the package.json file does indeed specify the main key.

@geekjuice
Copy link
Contributor

The version of tether included in your project is 0.6.5 which did not have the main field in the package.json resulting in the error you are seeing. For some reason, ^0.6.5 in your package.json doesn't seem to bump tether to version >0.6.5 which is what I expected, but as long as you specifiy a version >=0.7.0, it should work.

Update:
v0.6.5 package.json
v0.7.0 package.json

@davekiss
Copy link

davekiss commented Jun 3, 2015

@geekjuice still getting this with 0.7.2, so I must be doing something wrong. See something glaring in my package.json?

{
  "main": "app.js",
  "browserify": {
    "transform": [
      "browserify-shim"
    ]
  },
  "browser": {
    "backbone.supermodel" : "../bower_components/backbone.supermodel/index.js",
    "magnific-popup"      : "../bower_components/magnific-popup/dist/jquery.magnific-popup.min.js",
    "tether"              : "../bower_components/tether/tether.min.js",
    "tether-drop"         : "../bower_components/tether-drop/dist/js/drop.min.js",
    "tether-tooltip"      : "../bower_components/tether-tooltip/dist/js/tooltip.min.js"
  },
  "browserify-shim": {
    "jquery"              : "global:jQuery",
    "backbone"            : "global:Backbone",
    "underscore"          : "global:_",
    "rivets"              : "global:rivets",
    "backbone.supermodel" : "Backbone.SuperModel",
    "magnific-popup"      : "jQuery.magnificPopup",
    "tether"              : "Tether",
    "tether-drop"         : "Drop",
    "tether-tooltip"      : "Tooltip"
  },
  "devDependencies": {
    "browserify": "^10.2.3",
    "browserify-shim": "^3.8.7"
  }
}

@geekjuice
Copy link
Contributor

Could it be because you have your bower_components directory a level above where your package.json is? When I have my bower_components, node_modules, and package.json all on the same level, I run into no issues, but if I structure the directory like how you have it, I get this error.

@davekiss
Copy link

davekiss commented Jun 4, 2015

@geekjuice argh. sure was. thanks for helping with that. hopefully this helps someone else.

@geekjuice
Copy link
Contributor

No problem 😸

@mitogh
Copy link

mitogh commented Jan 7, 2016

Thank you @davekiss that work for me ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants