**编辑:我解决了这个问题。
对于使用Meteor的导入,您必须将代码放在/ imports /目录中。这是构建应用程序的official guide。这很奇怪,因为我在没有使用推荐的文件结构的情况下导入和导出大多数东西都很好。只有css导入无效。**
每当从npm包导入css时,我都会收到以下错误:
W20161023-13:23:17.701(-4)? (STDERR) /Users/mattmacpherson/Code/project/node_modules/codemirror/lib/codemirror.css:3
W20161023-13:23:17.701(-4)? (STDERR) .CodeMirror {
W20161023-13:23:17.701(-4)? (STDERR) ^
W20161023-13:23:17.702(-4)? (STDERR)
W20161023-13:23:17.702(-4)? (STDERR) SyntaxError: Unexpected token .
W20161023-13:23:17.703(-4)? (STDERR) at exports.runInThisContext (vm.js:53:16)
W20161023-13:23:17.703(-4)? (STDERR) at Module._compile (module.js:373:25)
W20161023-13:23:17.704(-4)? (STDERR) at Object.Module._extensions..js (module.js:416:10)
W20161023-13:23:17.704(-4)? (STDERR) at Module.load (module.js:343:32)
W20161023-13:23:17.704(-4)? (STDERR) at Module.Mp.load (/Users/mattmacpherson/.meteor/packages/babel-compiler/.6.9.1_1.15j1r1l++os+web.browser+web.cordova/npm/node_modules/reify/node/runtime.js:16:23)
W20161023-13:23:17.704(-4)? (STDERR) at Function.Module._load (module.js:300:12)
W20161023-13:23:17.704(-4)? (STDERR) at Module.require (module.js:353:17)
W20161023-13:23:17.705(-4)? (STDERR) at require (internal/module.js:12:17)
W20161023-13:23:17.705(-4)? (STDERR) at npmRequire (/Users/mattmacpherson/Code/project/.meteor/local/build/programs/server/npm-require.js:129:10)
W20161023-13:23:17.705(-4)? (STDERR) at Module.Mp.useNode (packages/modules-runtime/modules-runtime.js:69:1)
上面的示例是在导入codemirror的css时,但我也遇到了许多其他软件包的错误,包括react-s-alert和medium-draft。
这是我的.babelrc文件:
{
"plugins": [
"transform-class-properties"
],
"presets": [
"babel-preset-es2015",
"babel-preset-react",
"babel-preset-stage-2"
]
}