简体   繁体   中英

Javascript not importing npm package installed from git

I have a package in my dependencies in package.json of npm. I have included the package from github in following way-

"dependencies": {
    "@aeternity/aepp-components": "git+https://git@github.com/aeternity/aepp-components.git#feature/v3",`
}

When I run npm install , everything installs, and I can see the module in node_modules folder. However when I try to import , and run , npm gives an error saying

dependancy not found
To install it, you can run: npm install --save aepp-components

What am i doing wrong here?

Edit: Snippet I used to import:

import AeButton from 'aepp-components'

You need to do

import { AeButton } from '@aeternity/aepp-components'

see that how AeButton is imported using destructuring. And @aeternity specifies the default root source for the files and helps you map your file imports to it. Use that and it will work. You can also have a look at here in the doc

When you have @something/package-name , this is the name of the entire package, you have to import using this full name. Now, why?

This is called a scoped package, and @something is the scope of that package. You can check more about scoped packages here .

Some packages exports items/components/whatever inside an object, which requires you to use the destructuring method. You can only be sure how it is imported if you look at the docs, otherwise you would need to deep into the codebase.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM