cannot get/ 에러 원인
0
1. npm run dev를 실행하면
아래와 같은 코드가 나오고 compiled successfully 라고 뜹니다.
하지만 상단에 보시면, project is running at : ________빈칸
&
컴포넌트 내부에 작성한 문자가 아닌, 로컬을 열면 cannot get / 이 뜨는데 원인이 뭘까요 ?

2. devServer:{
port: 3090,
publicPath:'/dist/'
}
윗 코드 작성 자체가 에러가 뜹니다..(빨간밑줄) 

해결시도1) publicPath코드 삭제
해결시도2) static :{}안에 넣어주기
시도해봤는데도 cannot get/ 이 뜨네요
아래는 webpack.config,ts파일 입니다
```js
import path from 'path';
// import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
import webpack from 'webpack';
// import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
// import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
const isDevelopment = process.env.NODE_ENV !== 'production';
const config: webpack.Configuration = {
name: 'sleact',
mode: isDevelopment ? 'development' : 'production',
devtool: !isDevelopment ? 'hidden-source-map' : 'eval',
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
alias: {
'@hooks': path.resolve(__dirname, 'hooks'),
'@components': path.resolve(__dirname, 'components'),
'@layouts': path.resolve(__dirname, 'layouts'),
'@pages': path.resolve(__dirname, 'pages'),
'@utils': path.resolve(__dirname, 'utils'),
'@typings': path.resolve(__dirname, 'typings'),
},
},
entry: {
app: './client',
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: { browsers: ['last 2 chrome versions'] },
debug: isDevelopment,
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
},
exclude: path.join(__dirname, 'node_modules'),
},
{
test: /\.css?$/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
],
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
publicPath: '/dist/app.js',
},
devServer: {
port: 3090,
static : {publicPath:'/dist/'} ,
},
};
// devServer: {
// historyApiFallback: true,
// port: 3090,
// devMiddleware: { publicPath: '/dist/' },
// static: { directory: path.resolve(__dirname) },
// proxy: {
// '/api/': {
// target: 'http://localhost:3095',
// changeOrigin: true,
// ws: true,
// },
// },
// },
// };
// if (isDevelopment && config.plugins) {
// config.plugins.push(new webpack.HotModuleReplacementPlugin());
// config.plugins.push(
// new ReactRefreshWebpackPlugin({
// overlay: {
// useURLPolyfill: true,
// },
// }),
// );
// config.plugins.push(new BundleAnalyzerPlugin({ analyzerMode: 'server', openAnalyzer: false }));
// }
// if (!isDevelopment && config.plugins) {
// config.plugins.push(new webpack.LoaderOptionsPlugin({ minimize: true }));
// config.plugins.push(new BundleAnalyzerPlugin({ analyzerMode: 'static' }));
// }
export default config;
```
아래는 package.json파일입니다
```js
{
"name": "sleact-front",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "cross-env TS_NODE_PROJECT=\"tsconfig-for-webpack-config.json\" webpack serve --env development"
},
"author": "dahee",
"license": "MIT",
"dependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.0",
"@babel/preset-react": "^7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@types/react": "^17.0.34",
"@types/react-dom": "^17.0.11",
"babel-loader": "^8.2.3",
"cross-env": "^7.0.3",
"css-loader": "^6.5.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"style-loader": "^3.3.1",
"typescript": "^4.4.4",
"webpack": "^5.63.0"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/webpack": "^5.28.0",
"@types/webpack-dev-server": "^4.3.1",
"eslint": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"ts-node": "^10.4.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.4.0"
}
}
```
아래는 tsconfig-for-webpack-config.son파일입니다.
```js
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "Node",
"target": "es5",
"esModuleInterop": true
}
}
```
react
typescript
클론코딩
回答 1
0
제가 겪었던 문제와 동일한 것 같아 링크 첨부합니다!
https://www.inflearn.com/chats/343209
슬라이드 오타
0
5
0
강의 소스 코드는 어디서 볼수 있나여?
1
15
1
전체적인 개발에 대해 문의드립니다.
1
26
1
챌린지 시작일 문의
0
19
0
17강 강의에 목데이터 첨부파일이 없습니다.
2
23
2
줄바꿈 시 \ 필수인가요?
0
28
2
2605 이후 최신 클로드코드 강의 추가 부탁드립니다.
0
24
2
커리큘럼 문서 제공받을 수 있을까요?
0
24
1
ThemeProvider를 이용해서 NextThemeProvider를 따로 생성하여 Layout.tsx에 적용하는 이유는 뭘까요?
0
15
1
인덱스드 엑세스타입 실무질문
0
15
2
mission 09-01 을 수행할 수 없어요
0
25
1
outputStyle 설정하는데 어디서 문제일까요?
0
28
3
test.txt파일 삭제시 rm명령어이니 클로드의 질문이 있어야 한다고 하셨는데
0
22
2
검은화면
0
31
3
강의교환링크안열려요.....
0
30
2
영상재생에러 [확인부탁드려요!!!]
0
26
2
클로드 채팅에서 코드로 넘어가기
0
41
2
Context API vs Zustand 그리고 Auth
0
38
2
110강부터 따라가기가 힘듭니다...
0
60
2
npm install 안될 때
0
232
0
loadable 사용해서 코드스플리팅 적용시 나타나는 에러
0
406
0
WebSocket이 제대로 연결되지 않는 것 같습니다
0
317
1
back 폴더에서 npm install 시 에러가 발생하시는 분들 참고
1
258
0
폴더구조 질문입니다.
0
229
0

