我尝试将 proj4js (2.5.0) 作为 ES6 模块包含在 webpack (4.27.1) 项目中。
import proj4 from 'proj4';
这导致了这个错误:
ERROR in ./node_modules/proj4/package.json
Module parse failed: Unexpected token m in JSON at position 0 while parsing near 'module.exports = __w...'
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token m in JSON at position 0 while parsing near 'module.exports = __w...'
我能做些什么来绕过这个错误?
查看 proj4js github 页面上的问题报告,似乎 json-loader 执行了两次,因为 proj4js 明确需要 package.json:
proj4js/lib/version.js:
export {version as default} from '../package.json';