fixing errors
npm "createproxymiddleware is not a function" 에러 해결법
fulladdr
2020. 9. 10. 20:39
create-react-app 하고 npm을 킬 때 "createproxymiddleware is not a function"이라는 에러가 떴다.
구글링을 해봐도 Proxy is not a function이라는 에러가 뜨는 경우는 있어도 createproxymiddleware is not a function이라는 에러가 발생하는 경우는 없었다.
여러가지 해보다가 해결했는데,
1. 확인해보니 http-proxy-middleware가 버전업이 되어서 쓰는 법이 바꿨다고 한다.
2. 그래서 나는 버전업된 버전을 사용하고 있었다.
3. 그러나 구버전을 써야 내 vscode가 동작한다
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
이게 신버전이고
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
proxy({
target: 'http://localhost:5000',
changeOrigin: true,
})
);
};
이게 구버전이다.