【发布时间】:2016-07-13 19:09:54
【问题描述】:
我刚开始使用gulp-starter。我从 GIT 存储库中包含了一个私有 npm 包(名为“Pigeon”),但在让一切顺利运行时遇到了问题。包的安装很顺利,所有文件都在node_modules 中,包括它的所有依赖项。
myApp/node_modules/pigeon/index.js:
export MyModule from './my-module.js';
myApp/src/app.js:
import ClientPigeoneer from 'pigeon';
Webpack 加载器:
var webpackConfig = {
context: 'myApp/src/scripts',
plugins: [],
resolve: {
root: 'myApp/src/scripts',
extensions: ['', '.js', '.json']
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: ["es2015", "stage-1"]
}
]
}
}
控制台输出:
ERROR in ./~/pigeon/index.js
Module parse failed: /Users/mirague/Projects/myApp/node_modules/pigeon/index.js Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| export MyModule from './my-module';
|
@ ./src/scripts/app.js 9:14-31
如何让 Webpack 解析这个包?我需要添加另一个加载器吗?
【问题讨论】: