ryy77
ryy77

Reputation: 1294

Error: Module not found: Error: Can't resolve './src/api' in 'D:\opensource\sound-redux\node_modules\soundcloud'

I try to create a soundcloud app and I received this error(ERROR in ./node_modules/soundcloud/index.js Module not found: Error: Can't resolve './src/api' in 'D:\opensource\sound-redux\node_modules\soundcloud') See the below image

enter image description here

I installed the module npm i --save soundcloud (see the image).

Also, I attached the ApiUtils.js file where I initiate the module(see the code).

/* global fetch */
/* global window */
import camelize from 'camelize';
import SC from 'soundcloud';

export const callApi = (url, options) =>
  fetch(url, options)
    .then(
      response => (response.ok
        ? response.json()
        : Promise.reject(response.text())
      ),
      error => Promise.reject(error))
    .then(
      json => ({ json: camelize(json) }),
      error => ({ error }))
    .catch(error => ({ error }));

export const loginToSoundCloud = (clientId) => {
  SC.initialize({
    client_id: clientId,
    redirect_uri: `${window.location.protocol}//${window.location.host}/api/callback`,
  });

  return SC.connect()
    .then(
      json => ({ json: camelize(json) }),
      error => ({ error }),
    )
    .catch(error => ({ error }));
};

I will appreciate any help.

Upvotes: 0

Views: 524

Answers (1)

Dolf Barr
Dolf Barr

Reputation: 529

After small research, it seems like the problem is in library (v3.3.1). The best option now is to stick with version v3.3.0 for now (seems workable from npm):

"dependencies": {
  ...
  "soundcloud": "3.3.0"
  ...
}

Or, build soundcloud lib locally.

Also, there's the issue described in the package repo on GitHub: https://github.com/soundcloud/soundcloud-javascript/issues/49

And new issue for this problem in v3.3.1: https://github.com/soundcloud/soundcloud-javascript/issues/93

Upvotes: 1

Related Questions