Webpack错误:无法找到模块"。"

时间:2017-12-13 20:40:46

标签: node.js reactjs webpack

我正在使用musixmatch-sdk中的api,并使用webpack构建项目时出错。

我正在使用webpack 2reactnode

import网站上的默认musixmatch为:

var MusixmatchApi = require('../../build/javascript-client/src/index');

但这确实有效并且出现此错误:

ERROR in ./build/javascript-client/src/index.js<br/>
    Module not found: Error: Can't resolve 'ApiClient' in '/Users/myname/lyrix/build/javascript-client/src'<br/>
     @ ./build/javascript-client/src/index.js 28:4-2099<br/>
     @ ./src/server.js

所以我用绝对路径写了它:

const MusixmatchApi = require(path.join(__dirname,'../build/javascript-client/src/index'));

这适用于webpack的开发模式,但我收到此警告:

WARNING in ./src/server.js
    33:20-102 Critical dependency: the request of a dependency is an expression
     @ ./src/server.js

因此,如果我想构建生产项目,我会收到错误:

Error: Cannot find module "."<br/>
    at /Users/myname/lyrix/src/server-es5.js:1:16712<br/>
    at Object.<anonymous> (/Users/myname/lyrix/src/server-es5.js:1:16782)
你能帮我吗?

0 个答案:

没有答案