javascript - 模块解析失败意外令牌webpack反应nextjs
问题描述
尝试将react-native-elements
npm 包导入 nextjs 应用程序,但 webpack 不喜欢该包中的文件之一。我是否在 next.config.js 文件中遗漏了一些配置或其他内容?
错误
error - ./node_modules/react-native-vector-icons/lib/create-multi-style-icon-set.js 108:23
Module parse failed: Unexpected token (108:23)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| function createStyledIconClass(selectClass = '') {
| class IconClass extends PureComponent {
> static propTypes = styleNames.reduce((acc, name) => {
| acc[name] = PropTypes.bool;
| return acc;
Could not find files for /mypage in .next/build-manifest.json
Could not find files for /mypage in .next/build-manifest.json
next.config.js
const nodeExternals = require('webpack-node-externals');
module.exports = {
webpackDevMiddleware: (config) => {
config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
};
return config;
},
target: 'server',
externals: [nodeExternals()],
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
}
}
解决方案
推荐阅读
- selenium - 我们如何在 Selenium webdriver 中使用相同窗口 ID 从一个窗口切换到另一个窗口?
- sqlite - 如何将 guid 插入 sqlite UNIQUEIDENTIFIER 列
- javascript - 在浏览器应用中使用 protobuf.js
- python - 使用 get_dummies() 包含更多列
- css - is it possible to shrink background image and keep the offsets
- google-cloud-platform - 在 gcloud 中导入虚拟磁盘的问题 (Centos 6.7)
- php - Laravel deny edit posts for users if current user not author
- javascript - Filtering array of objects by removing unwanted nested object properties
- android - 找不到 lint-checks.jar
- html - 带有供应主题“shopify”的产品页面图像滑块