我正在使用Node V6.11.0和npm 3.10.10。最近我在考虑使用markdown-it,其中一个依赖项是实体。在我添加此依赖项之前,一切正常,但是当我尝试安装npm install markdown-it --save
并再次构建时,我收到此错误,如下所示:
> access_mgr@0.0.1 build /home/jgu/repos/access_mgr
> webpack --config webpack.config.js --progress --colors
Hash: 05d4660f200286bd0530
Version: webpack 1.15.0
Time: 13572ms
Asset Size Chunks Chunk Names
favicon.ico 1.41 kB [emitted]
main-05d4660f200286bd0530.js 2.2 MB 0 [emitted] main
main-05d4660f200286bd0530.css 435 kB 0 [emitted] main
+ 274 hidden modules
ERROR in ./~/entities/maps/entities.json
Module parse failed: /home/jgu/repos/access_mgr/node_modules/entities/maps/entities.json Unexpected token (1:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:9)
at Parser.pp$4.raise (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/home/jgu/repos/access_mgr/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/home/jgu/repos/access_mgr/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/home/jgu/repos/access_mgr/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/home/jgu/repos/access_mgr/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/home/jgu/repos/access_mgr/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /home/jgu/repos/access_mgr/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/home/jgu/repos/access_mgr/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /home/jgu/repos/access_mgr/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)
@ ./~/markdown-it/lib/common/entities.js 6:17-55
Child extract-text-webpack-plugin:
+ 7 hidden modules
然后我运行节点REPL并粘贴require('entities/maps/entities.json');
,这很好。我检查了json文件,它只是名称到特殊unicode符号的映射。我错过了什么导致webpack失败?