我做了以下步骤
npm install moment --save
import moment from "moment"
当我想导入momentjs时,我收到以下错误:
Uncaught TypeError: Cannot assign to read only property 'clone' of object '#
时刻版:^ 2.22.1
我使用webpack 4.
尝试像这样导入也失败了同样的错误:
import moment from "moment/src/moment"
有人能帮助我吗?我真的不知道如何解决这个问题.
我的Webpack配置:
const path = require('path')
const BrowserSyncPlugin = require("browser-sync-webpack-plugin")
var webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
entry: './src/js/index.js',output: {
path: path.resolve(__dirname,'static'),filename: 'monitor-bundle.js'
},devtool: 'source-map',mode: 'development',module: {
rules: [
{
test: /\.js$/,exclude: /node_modules/,use: {
loader: "babel-loader"
}
},{
test: /\.css$/,}
]
},watch: true,plugins: [
new BrowserSyncPlugin({
watchOptions: {
poll: true
},host: "localhost",port: "1337",proxy: "http://localhost:80/",files: ["./static/monitor-bundle.js"],open: true,reloadDelay: 0,reloadDebounce: 0,browser: ["chromium","google chrome"]
}),new BundleAnalyzerPlugin(),],};
最佳答案