Css 您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。”;
我正在使用Thread设置react项目的网页包,出现以下错误: ./src/app.js 67:6模块解析失败时出错:意外令牌 (67:6)您可能需要适当的加载程序来处理此文件类型, 目前没有配置加载程序来处理此文件。看见 ℹ 「wdm:未能编译 webpack.config.jsCss 您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。”;,css,reactjs,Css,Reactjs,我正在使用Thread设置react项目的网页包,出现以下错误: ./src/app.js 67:6模块解析失败时出错:意外令牌 (67:6)您可能需要适当的加载程序来处理此文件类型, 目前没有配置加载程序来处理此文件。看见 ℹ 「wdm:未能编译 webpack.config.js const path = require("path"); module.exports = { entry: "./src/app.js", output: { path: pa
const path = require("path");
module.exports = {
entry: "./src/app.js",
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js'
},
module:{
rules:[{
loader: 'babel-loader',
test: '/\.(js|jsx)$/',
exclude: /node_modules/
}]
},
devtool: 'cheap-module-eval-source-map',
devServer: {
contentBase: path.join(__dirname, 'public')
}
}
package.json
{
"name": "react",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"serve": "live-server public/",
"build": "webpack",
"dev-server": "webpack-dev-server"
},
"dependencies": {
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-preset-env": "1.5.2",
"babel-preset-react": "6.24.1",
"live-server": "^1.2.1",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"webpack": "^4.39.3",
"webpack-dev-server": "^3.8.0"
},
"devDependencies": {
"@babel/core": "^7.6.0",
"babel-loader": "^8.0.6",
"webpack-cli": "^3.3.8"
}
}
您正在使用不必要的转义字符:这不是必需的 将
测试:'/\.(js | jsx)$/',
替换为测试:/\.js$| jsx/,
它应该可以正常工作
我在我的机器上复制了您的问题,并发现了相同的问题,通过上述修复解决了该问题
希望这有帮助,快乐编码 所选答案缺少一些详细信息: 它应该是
测试:'/\.(js|jsx)$/'
,替换为测试:/\.js|\.jsx$/
\:在本例中为
|:是交替/或操作数
$:是行尾
希望这对你有用
资料来源:
将.babelrc文件添加到节点模块文件夹所在的同一文件夹中,并包含以下内容
{
"presets": ["@babel/preset-react"]
}
web未能编译。
/keyboardawarhoc.js 13:12
模块分析失败:意外令牌(13:12)
您可能需要适当的加载程序来处理此文件类型,目前没有配置加载程序来处理此文件。看见https://webpack.js.org/concepts#loaders 3.
|}来自“react native”
|从'react-native-iphone-x-helper'导入{isIphoneX}
从“/KeyboardAwareInterface”导入类型{KeyboardAwareInterface}
|
|const\u KAM\u DEFAULT\u TAB\u BAR\u HEIGHT:number=isIphoneX()?83 : 49
安装以下软件包并重新启动expo软件包
我发生此错误的原因很简单,因为文件位于项目的父文件夹中(即项目文件夹之外)
将文件移动到适当的文件夹将其修复。将下面提到的代码放入网页文件中。
mix.extend(
"graphql",
new (class {
dependencies() {
return ["graphql", "graphql-tag"];
}
webpackRules() {
return {
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: "graphql-tag/loader"
};
}
})()
);
mix.js("resources/js/app.js", "public/js").vue();
mix.graphql();
能否包含app.js
的源代码?同时添加jsx会引发错误您可能需要一个额外的加载器来处理这些加载器的结果。
我已经有了这个文件,但是我得到了上面的错误。
web Failed to compile.
<PATH>/KeyboardAwareHOC.js 13:12
Module parse failed: Unexpected token (13:12)
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 3
| } from ‘react-native’
| import { isIphoneX } from ‘react-native-iphone-x-helper’
import type { KeyboardAwareInterface } from ‘./KeyboardAwareInterface’
|
| const _KAM_DEFAULT_TAB_BAR_HEIGHT: number = isIphoneX() ? 83 : 49
mix.extend(
"graphql",
new (class {
dependencies() {
return ["graphql", "graphql-tag"];
}
webpackRules() {
return {
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: "graphql-tag/loader"
};
}
})()
);
mix.js("resources/js/app.js", "public/js").vue();
mix.graphql();