当我尝试将node-rsa
库包含在Webpack中时,如下所示:
import NodeRSA from 'node-rsa';
我收到以下错误:
ERROR in ./~/constants-browserify/constants.json
Module parse failed: /home/hencic00/Dropbox/Documents/Camelot/node_modules/constants-browserify/constants.json Unexpected token (2:12)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:12)
at Parser.pp$4.raise (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:2221:15)
at Parser.pp.unexpected (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:603:10)
at Parser.pp.semicolon (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:581:61)
at Parser.pp$1.parseExpressionStatement (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:966:10)
at Parser.pp$1.parseStatement (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:730:24)
at Parser.pp$1.parseBlock (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:981:25)
at Parser.pp$1.parseStatement (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:709:33)
at Parser.pp$1.parseTopLevel (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:638:25)
at Parser.parse (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:516:17)
at Object.parse (/home/hencic00/Dropbox/Documents/Camelot/node_modules/acorn/dist/acorn.js:3098:39)
at Parser.parse (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack/lib/Parser.js:902:15)
at DependenciesBlock.<anonymous> (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack/lib/NormalModule.js:104:16)
at DependenciesBlock.onModuleBuild (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack-core/lib/NormalModuleMixin.js:310:10)
at nextLoader (/home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack-core/lib/NormalModuleMixin.js:275:25)
at /home/hencic00/Dropbox/Documents/Camelot/node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
at Storage.finished (/home/hencic00/Dropbox/Documents/Camelot/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
at /home/hencic00/Dropbox/Documents/Camelot/node_modules/graceful-fs/graceful-fs.js:78:16
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
@ ./~/node-rsa/src/NodeRSA.js 10:16-36
似乎没有关于此主题的任何现有问题。 有什么想法吗?
答案 0 :(得分:0)
只需将json loader添加到您的webpack配置中。