Closed lauraeci closed 9 years ago
Are underscore
and machina
listed in your application's package.json file and also in node_modules
directory?
This is what we are starting from:
"machina": "^0.3.6", "underscore": "^1.6.0"
didn't have a package.json but I ran npm init and that's what it came up with.
@lauraeci Sorry I didn't take just a few seconds longer to look at your post before commenting. Machina has switched to a dependency on lodash, and has dropped the factory pattern. Using this should work for you:
var machina = require('machina');
var DeviceFsm = machina.Fsm.extend({
});
Where did you see the code that includes underscore? If its in the wiki or repo, I want to fix it. If its in a presentation, it's just out dated!
Hi @lauraeci, @dcneiner is correct, machina dropped underscore in favor of lodash in v0.3.7. Looks like the issue is related to the ^
character before the version number in your snippet above. That will allow npm to match against v0.3.7-v0.3.8 - if newer versions are available (which they are) and thus you're really getting an updated version that uses lodash instead. You can peg to a specific version by removing the ^
if you need to.
I'm sorry for the trouble - the jump for v0.3.6 to v0.3.7 should really have been a v0.4.0 (I'm still facepalming at past-me for trolling future me). You can see the specific version of machina npm installed by running npm ls machina
in your project directory. When I tried npm install machina@^0.3.6
, it pulled down v0.3.8.
Keep me posted if you run into more trouble!
@lauraeci Also - I meant to add, if you're upgrading to v1.0.0-1, be sure to change the version in your package.json that has machina at ^0.3.6. @dcneiner's example on how to require it should work. Thanks!
Thanks @dcneiner @ifandelse for the clarification. Yes, it looks like v1.0.0-1 wasn't installed. We actually didn't have a package.json which was causing my confusion (added one now), it was difficult to tell which version was installed. One thing I might suggest in the wiki is if the code blocks were separated into different examples to support different versions it might be a little easier to read. I think we must have pulled that old code from snippet on the web or something, probably an old stack overflow question.
Great module - its been working really well. Thanks for the help on upgrading, it works now! Cheers, -Laura
@lauraeci So glad to hear things are working well! Feel free to reach out if you run into any questions, etc.
Any suggestions of how to fix this would be very appreciated. Thanks!