[英]Module parse error for an NPM package
I'm receiving a weird error at the build time utilizing Webpack. 使用Webpack在构建时收到一个奇怪的错误。 The error in question is referring to Got's
package.json
file that I'm importing. 有问题的错误是指我要导入的Got的
package.json
文件。
Module parse failed: .../node_modules/got/package.json Unexpected token (2:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:8)
Curious to what is causing this and if this is on my end or Got's end. 好奇是什么原因造成的,以及这是在我还是在头上。
Node version : v4.2.0 节点版本 :v4.2.0
NPM version : 2.14.7 NPM版本 :2.14.7
The problem is that you are importing a json, but don't have the appropriate loader configured. 问题是您要导入json,但未配置适当的加载程序。 In your webpack-confing add a json loader to your loaders.
在您的webpack-confing中,将json加载程序添加到您的加载程序中。 It should look something like this:
它看起来应该像这样:
var config = {
....
module: {
loaders: [
...
{
test: /\.json/,
loader: 'json'
}
]
},
....
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.