reactjs - TypeError: Object(...) is not a function uuid in reactjs and webpack
问题描述
我正在使用带有 webpack 4 的 reactjs 并收到此消息: TypeError: Object(...) is not a function
应用程序.js:
import { v4 as uuidv4 } from 'uuid';
console.log(uuidv4());
.babelrc:
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-transform-runtime"]
}
webpack.common.js
const path = require('path');
module.exports = {
entry: {
app: './src/index.jsx'
},
module: {
rules: [
{
test: /\.js|jsx$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.png|jpe?g|gif|ttf|woff|woff2|eot|svg$/,
use: [
{
loader: 'file-loader'
}
]
}
]
},
resolve: {
extensions: ['.js', '.jsx']
},
output: {
filename: 'js/[name].[chunkhash].js',
chunkFilename: 'js/[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
..........
};
解决方案
推荐阅读
- javascript - fetch api - 如何将数组附加为搜索参数
- intellij-idea - AspectJ/Jetty/Java-8:错误扫描条目 UpdateParserFiles.class
- c# - 使用枚举加载组合框 - UWP 和 MVVM
- python - 将“子子记录列(作为字典列表)”转换为更传统的“SQL 连接”输出样式
- android - 小部件固定大小的图标 Android
- reactjs - Next js中的嵌套路由
- oauth-2.0 - ASP.NET Core 2.1:如何访问控制器代码中的“动作声明”(尤其是在用户注册期间)?
- r - 使用 R 和 OS-X 的 XGBoost 并行执行失败
- c# - 如何在 Unity3D 中的 X 轴和 Z 轴上进行拖放?
- amazon-web-services - 到 SQS 的 S3 事件通知:未找到 kms 配置