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

Should/Underscore example doesn't work with global npm installation #106

Closed
tvararu opened this issue Mar 7, 2014 · 4 comments
Closed

Comments

@tvararu
Copy link

tvararu commented Mar 7, 2014

Installed should and underscore globally as described in examples/advanced/tests/readme.md, but that just caused the test suite to error:

MBA13 ➜  advanced git:(master) npm install -g should underscore
npm http GET https://registry.npmjs.org/should
npm http GET https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/should
npm http 200 https://registry.npmjs.org/underscore
underscore@1.6.0 /usr/local/lib/node_modules/underscore

should@3.1.3 /usr/local/lib/node_modules/should
MBA13 ➜  advanced git:(master) laika

  injecting laika...
  loading phantomjs...
  loading initial app pool...
  cleaning up injected code


module.js:340
    throw err;
          ^
Error: Cannot find module 'should'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/tvararu/Github/laika/examples/advanced/tests/$setup.js:1:72)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

The test suite does work however if you install them locally:

MBA13 ➜  advanced git:(master) npm install should underscore
npm http GET https://registry.npmjs.org/should
npm http GET https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/should
npm http 304 https://registry.npmjs.org/underscore
underscore@1.6.0 ../../node_modules/underscore

should@3.1.3 ../../node_modules/should
MBA13 ➜  advanced git:(master) laika

  injecting laika...
  loading phantomjs...
  loading initial app pool...


  Posts
`runAllFixtures` executed
    ✓ simple test


  1 passing (113ms)

  cleaning up injected code
@AdamBrodzinski
Copy link
Contributor

@tvararu Where did you install the node modules? It appears like they were installed from the root of advanced? When I try that I get this from the meteor server

ReferenceError: require is not defined
    at app/node_modules/should/lib/ext/browser/jquery.js:12:12
    at /Users/adam/Desktop/advanced/.meteor/local/build/server/server.js:286:12
    at Array.forEach (native)
    at Function._.each._.forEach (/Users/adam/.meteor/tools/11f45b3996/lib/node_modules/underscore/underscore.js:79:11)
    at run (/Users/adam/Desktop/advanced/.meteor/local/build/server/server.js:227:7)
=> Exited with code: 1
=> Meteor server restarted

If I try installing in tests I get this error from laika:

/Users/adam/Desktop/advanced/tests/node_modules/should/lib/ext/chain.js:10
    Object.defineProperty(Assertion.prototype, name, {
           ^
TypeError: Cannot redefine property: an
    at Function.defineProperty (native)
    at addLink (/Users/adam/Desktop/advanced/tests/node_modules/should/lib/ext/chain.js:10:12)
    at Array.forEach (native)
    at module.exports (/Users/adam/Desktop/advanced/tests/node_modules/should/lib/ext/chain.js:17:72)
    at Function.should.use (/Users/adam/Desktop/advanced/tests/node_modules/should/lib/should.js:91:3)
    at Object.<anonymous> (/Users/adam/Desktop/advanced/tests/node_modules/should/lib/browser.js:11:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

@tvararu
Copy link
Author

tvararu commented Apr 1, 2014

Yeah, they don't work when they are installed in tests/node_modules. What I ended up doing was installing them in the root of the meteor project in a folder that I called .node_modules, commiting that to version control, and doing this in tests/$setup.js:

should = require('../.node_modules/should').should;

@AdamBrodzinski
Copy link
Contributor

@tvararu Awesome! thanks so much! Working great.

@arunoda
Copy link
Owner

arunoda commented Apr 1, 2014

We will be having NPM support pretty soon.
Right now, this is a good solution and you also can install the module
globally an use it.


Arunoda Susiripala
I curate Meteor Weekly - Check it
out!http://meteorhacks.com/meteor-weekly/?utm_source=email-footer&utm_medium=email&utm_campaign=meteorweekly

On Wed, Apr 2, 2014 at 1:44 AM, Adam Brodzinski notifications@github.comwrote:

@tvararu https://github.com/tvararu Awesome! thanks so much! Working
great.


Reply to this email directly or view it on GitHubhttps://github.com//issues/106#issuecomment-39252929
.

@tvararu tvararu closed this as completed Nov 27, 2019
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

3 participants