代码之家  ›  专栏  ›  技术社区  ›  ryy77

错误:找不到模块:错误:无法解析“D:\opensource\sound redux\node\u modules\soundcloud”中的“/src/api”

  •  0
  • ryy77  · 技术社区  · 6 年前

    找不到模块:错误:无法解析“D:\opensource\sound redux\node\u modules\soundcloud”中的“/src/api”,请参见下图

    enter image description here

    我安装了模块NPMIsaveSoundCloud(参见图)。

    此外,我还附加了ApiUtils.js文件,在其中启动模块(请参阅代码)。

    /* 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 }));
    };

    1 回复  |  直到 6 年前
        1
  •  1
  •   Dolf Barr    6 年前

    经过小规模的研究,问题似乎出在库中(v3.3.1)。现在最好的选择是暂时坚持使用v3.3.0版(从npm看来是可行的):

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

    或者,建造 soundcloud 本地lib。

    此外,GitHub上的一揽子回购协议中描述了一个问题: https://github.com/soundcloud/soundcloud-javascript/issues/49

    v3.3.1中针对此问题的新版本: https://github.com/soundcloud/soundcloud-javascript/issues/93