Closed gotjoshua closed 6 years ago
the package name is lowercase. Try var ObjectModel = require('objectmodel').ObjectModel;
Interesting situation: I am using meteor, and I think the issue had something to do with mixed styles of import and require...
when i use this:
import { ObjectModel, SetModel } from 'objectmodel';
var BasicModel = require('ObjectModel').BasicModel;
i get this error (on the require line):
Uncaught Error: Cannot find module 'ObjectModel'
in modules-runtime.js?hash=7f4df5777c8321c08a58834753e5d5a010366eda:218
ok, getting more weird:
when i use this (in the same file as above):
var ObjectModel = require('ObjectModel').ObjectModel;
var SetModel = require('ObjectModel').SetModel;
var BasicModel = require('ObjectModel').BasicModel;
then it throws an error in a different file that is using the recommended syntax:
import { ObjectModel } from 'objectmodel';
...
Uncaught Error: Cannot find module 'objectmodel'
but if i convert all uses of ObjectModel to the CamelCase require, then there are no errors.
Perhaps it has something to do with babel / meteor's legacy conversion stuff.
Anyyyywayyyy - i will convert to the import syntax from now on.
The package name is supposed to be lowercase. I highly suggest you to use lowercase everywhere, no matter if you are using CommonJS or ES Modules.
Yeah, I get that now... just don't understand why it would only work (or work at all for that matter) with CamelCase with require at one point... but i'll let it pass as a quirk and follow your suggestion. Thanks.
Here is (some of) the output of depcheck:
I guess this has to do with import methods:
I am using this style (in several files): var ObjectModel = require('ObjectModel').ObjectModel; When I replace one of those require statements with: import { ObjectModel } from 'objectmodel'; then the unused dependency goes away.
Is this "normal" ?