arifulhb / amazon-pa-api50

Amazon Product Advertising API v5.0 for JavaScript and NodeJs
https://www.npmjs.com/package/amazon-pa-api50
MIT License
29 stars 9 forks source link

Dependencies were not found #3

Open sajjadalis opened 4 years ago

sajjadalis commented 4 years ago

First of all, thanks for providing this easy solution. Official SDK config is a mess.

I have been trying official sdk earlier with my VueJS application and during compile in serve mode, i was getting dependencies were not found error. So i just tried amazon-pa-api50 but i have the same issue during compile process.

It works fine if i try to node amazon.js in console and i'm getting proper response (same for official sdk)

But when i including it inside .vue file then it won't work.

Failed to compile with 88 errors
These dependencies were not found:

* ApiClient in ./node_modules/amazon-pa-api50/sdk/src/index.js
* api/DefaultApi in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Availability in ./node_modules/amazon-pa-api50/sdk/src/index.js      
* model/BrowseNode in ./node_modules/amazon-pa-api50/sdk/src/index.js        
* model/BrowseNodeAncestor in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/BrowseNodeChild in ./node_modules/amazon-pa-api50/sdk/src/index.js   
* model/BrowseNodeChildren in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/BrowseNodeInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/BrowseNodesResult in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ByLineInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Classifications in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Condition in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ContentInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ContentRating in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Contributor in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/DeliveryFlag in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/DimensionBasedAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/DurationPrice in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ErrorData in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ExternalIds in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetBrowseNodesRequest in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetBrowseNodesResource in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetBrowseNodesResponse in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetItemsRequest in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetItemsResource in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetItemsResponse in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetVariationsRequest in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetVariationsResource in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/GetVariationsResponse in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ImageSize in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ImageType in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Images in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Item in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ItemIdType in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ItemInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ItemsResult in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/LanguageType in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Languages in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ManufactureInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/MaxPrice in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Merchant in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/MinPrice in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/MinReviewsRating in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/MinSavingPercent in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/MultiValuedAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferAvailability in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferCondition in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferCount in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferDeliveryInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferListing in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferLoyaltyPoints in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferMerchantInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferPrice in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferProgramEligibility in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferPromotion in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferSavings in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferShippingCharge in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferSubCondition in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/OfferSummary in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Offers in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/PartnerType in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Price in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ProductAdvertisingAPIClientException in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ProductAdvertisingAPIServiceException in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/ProductInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Properties in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/Refinement in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/RefinementBin in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/RentalOfferListing in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/RentalOffers in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SearchItemsRequest in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SearchItemsResource in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SearchItemsResponse in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SearchRefinements in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SearchResult in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SingleBooleanValuedAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SingleIntegerValuedAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SingleStringValuedAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/SortBy in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/TechnicalInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/TradeInInfo in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/TradeInPrice in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/UnitBasedAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/VariationAttribute in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/VariationDimension in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/VariationSummary in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/VariationsResult in ./node_modules/amazon-pa-api50/sdk/src/index.js
* model/WebsiteSalesRank in ./node_modules/amazon-pa-api50/sdk/src/index.js

To install them, you can run: npm install --save ApiClient api/DefaultApi model/Availability model/BrowseNode model/BrowseNodeAncestor model/BrowseNodeChild model/BrowseNodeChildren model/BrowseNodeInfo model/BrowseNodesResult model/ByLineInfo model/Classifications model/Condition model/ContentInfo model/ContentRating model/Contributor model/DeliveryFlag model/DimensionBasedAttribute model/DurationPrice model/ErrorData model/ExternalIds model/GetBrowseNodesRequest model/GetBrowseNodesResource model/GetBrowseNodesResponse model/GetItemsRequest model/GetItemsResource model/GetItemsResponse model/GetVariationsRequest model/GetVariationsResource model/GetVariationsResponse model/ImageSize model/ImageType model/Images model/Item model/ItemIdType model/ItemInfo model/ItemsResult model/LanguageType model/Languages model/ManufactureInfo model/MaxPrice model/Merchant model/MinPrice model/MinReviewsRating model/MinSavingPercent model/MultiValuedAttribute model/OfferAvailability model/OfferCondition model/OfferCount model/OfferDeliveryInfo model/OfferListing model/OfferLoyaltyPoints model/OfferMerchantInfo model/OfferPrice model/OfferProgramEligibility model/OfferPromotion model/OfferSavings model/OfferShippingCharge model/OfferSubCondition model/OfferSummary model/Offers model/PartnerType model/Price model/ProductAdvertisingAPIClientException model/ProductAdvertisingAPIServiceException model/ProductInfo model/Properties model/Refinement model/RefinementBin model/RentalOfferListing model/RentalOffers model/SearchItemsRequest model/SearchItemsResource model/SearchItemsResponse model/SearchRefinements model/SearchResult model/SingleBooleanValuedAttribute model/SingleIntegerValuedAttribute model/SingleStringValuedAttribute model/SortBy model/TechnicalInfo model/TradeInInfo model/TradeInPrice model/UnitBasedAttribute model/VariationAttribute model/VariationDimension model/VariationSummary model/VariationsResult model/WebsiteSalesRank

Also VSCode is showing this message on require. http://prntscr.com/qt023x

Any suggestion?

Thanks

arifulhb commented 4 years ago

Can you please share your package.json and how you are importing the package?

sajjadalis commented 4 years ago

@arifulhb Thanks for the reply and sorry for a bit late response.

Here is my package.json.

{
  "name": "earbudshop",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build"
  },
  "dependencies": {
    "amazon-pa-api50": "0.0.3",
    "axios": "^0.19.2",
    "cookieparser": "^0.1.0",
    "core-js": "^3.4.4",
    "js-cookie": "^2.2.1",
    "strapi-sdk-javascript": "^0.3.3",
    "vue": "^2.6.10",
    "vue-router": "^3.1.3",
    "vuex": "^3.1.2"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-router": "^4.1.0",
    "@vue/cli-plugin-vuex": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "@vue/eslint-config-prettier": "^5.0.0",
    "vue-template-compiler": "^2.6.10"
  }
}

I created a separate file for configuration

amazon.js

const Api = require('amazon-pa-api50')
const Config = require('amazon-pa-api50/lib/config')

// By Default all resources and will connect to United States
let myConfig = new Config();

/**
 * Add your Credentials Here
 */
myConfig.accessKey = 'APIKEY'
myConfig.secretKey = 'APISECRET' 
myConfig.partnerTag = 'partnetag'

const api = new Api(myConfig)

export default api;

Here is my code inside AddProducts.vue component.

<template>
    <div class="add-products">
        <button @click="getProducts" class="uk-button">Get Products</button>
    </div>
</template>

<script>
import api from '@/init/amazon.js'

export default {
    methods: {
        getProducts() {
            api.getItemById(['B079JD7F7G']).then((response) => {
                console.log(' ===== find by Item ids =====')
                console.log('data', response.data)
                }).catch((error) => {
                console.log('Error: ', error)
            })
        }
    }

}
</script>

When i run npm run serve. I get that above error during build process. I tried to import amazon-pa-api50 directly inside AddProducts.vue file but it gets the same error during build process.

If i include api.getItemById() inside amazon.js and run node amazon.js then i get response perfectly fine. As mentioned above, i had same issue with official sdk when i include it in .vue file. Any help what i'm doing wrong.

Thanks again.

sajjadalis commented 4 years ago

@arifulhb any help on this? What am i doing wrong?

Thanks for your time.

marco910 commented 2 years ago

@sajjadalis Could you resolve the issue? I'm having a very similar problem.

arifulhb commented 2 years ago

I will also have a look this weekend.