Webpack错误模块解析失败:意外令牌

时间:2018-10-01 11:02:03

标签: reactjs react-native webpack npm-install

npm -v 5.6.0

我在package.json文件中添加了"react-native-spinkit": "^1.1.1",然后运行npm install。我看到package-lock.json也用我添加的软件包进行了更新。但是当我运行webpack时,出现以下错误消息。

ERROR in ./~/react-native-spinkit/index.js
Module parse failed: /opt/app-root/src/themes/node_modules/react-native-spinkit/index.js Unexpected token (16:18)
You may need an appropriate loader to handle this file type.
| class Spinkit extends React.Component {
| 
|   static propTypes = {
|       type: PropTypes.string,
|       /**
 @ ./js/index.js 19:26-57
 @ multi ./js/index.js ./webpack.config.js

我刚刚在Spinner文件头中添加了index.js组件并运行webpack。

import React from 'react';
import { render } from 'react-dom';
import Chart from './Chart';
import Spinner from 'react-native-spinkit';
...

webpack.config.js

module.exports = {
  entry: ['./js/index.js'],
  output: {
    path: __dirname + "/js/",
    filename: 'favorite.bundle.js'
  },
  module: {
    loaders: [
      {test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader'},
      { test: /\.css$/, loader: "style-loader!css-loader" }
    ]
  }
};

0 个答案:

没有答案