@j.myon
You simply can use the name of the dependency from https://www.npmjs.com. If the dependency is named jointjs
, you can import it with ... from 'jointjs';
. Is it named joint-js
you import it with ... from 'joint-js';
Or have a look at your node_modules folder. You find the exact name within the dependency folder in the package.json
file. This file describes which name the dependency has and which other dependencies it uses …
It depends on the implementation of the module and how it is exported. Normally it is documented on the npmjs.org page of the module or its corresponding github page. In case of joint.js it is missing or I didn’t find it directly and I had to look in the source code.
The module exports everything here:
https://github.com/clientIO/joint/blob/master/index.js#L3
I highly suggest that you read this blogpost about ES6s’ module syntax, so you will get a gaps what the difference is between import jointjs from 'jointjs';
and import { jointjs } from 'jointjs';
.
The first imports the default export
, the second a simply a named export
. A module can have one or zero default exports
but multiple exports
;
For example, if my module exports the following:
export const A = 'a'; export const B = 'b'; export default A;
Now I want to import A, I can to it in two ways, as A will be exported as default export
and as standard named export
:
import A from 'my-module'; import { A } from 'my-module';
But when I want to import B from my module, I always have to use:
import { B } from 'my-module';
Yes and no. You can do both to install a npm package in your meteor project. But it is recommended that you use always meteor npm
with meteor. The background is, npm installs dependencies with the node version you currently have installed globally on your machine. Type in your terminal node -v
and you can see which version is installed.
When you install your npm packages with npm
only, your dependencies will be installed with your globally installed node version. The case is, meteor brings its own version of node. So when you install a dependency with meteor npm
it uses the current node version of meteor which is 4.x.x.
This could lead to issues, when you use npm ...
instead of meteor npm ...
when the versions of meteors’ node and your machines’ node is different and the way how the versions handle dependencies differentiate. For example, older node versions may use npm 2 vs newer versions of node use npm 3. This could case issues.
Just use meteor npm
and you are safe.