인프런 커뮤니티 질문&답변
babel-node문제로 실행이 되지 않습니다.
작성
·
2.5K
0
명령어를 실행하면
"'babel-node'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다."
라고 뜹니다. 인터넷에 아무리 뒤져바도 해결하는 방법이 나와있지 않아서 도움요청을 드립니다.
{
  "name": "blog",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "nodemon --exec babel-node ./server/server.js "
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-node": "^0.0.1-security",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "helmet": "^4.2.0",
    "hpp": "^0.2.3",
    "moment": "^2.29.1",
    "mongoose": "^5.11.8"
  },
  "devDependencies": {
    "@babel/cli": "^7.12.10",
    "@babel/core": "^7.12.10",
    "@babel/node": "^7.12.10",
    "@babel/polyfill": "^7.12.1",
    "@babel/preset-env": "^7.12.11",
    "babel-loader": "^8.2.2",
    "morgan": "^1.10.0",
    "nodemon": "^2.0.6"
  }
}
답변 6
0
0
만약에 그러시다면... node를 14버전 이상으로 설치하시고,
package.json에
"type":"module" 한줄만 추가해주시면 babel을 안쓰셔도 ES6 모듈을 사용해서 강의를 따라가실수 있습니다.
대신 babel 관련 설정은 다 빼주시면 그대로 진행가능하십니다.
아니면 백엔드는 그냥 Common JS 문법으로 진행하시겠다하시면 node 버전업이나 babel 안쓰셔도 가능하십니다.
******************************************************************************************************
[방법2]
| { | |
| "name": "blog", | |
| "version": "1.0.0", | |
| "main": "index.js", | |
| "scripts": { | |
| "dev": "nodemon ./server/server.js --exec babel-node --ignore './client'", | |
| "prebuild": "cd client && npm run build", | |
| "build": "babel server --out-dir build", | |
| "build:server": "babel server --out-dir build" | |
| }, | |
| "author": "", | |
| "license": "ISC", | |
| "keywords": [], | |
| "description": "", | |
| "dependencies": { | |
| "aws-sdk": "2.706.0", | |
| "bcryptjs": "2.4.3", | |
| "cors": "2.8.5", | |
| "dotenv": "8.2.0", | |
| "express": "4.17.1", | |
| "greenlock-express": "4.0.3", | |
| "helmet": "3.22.0", | |
| "hpp": "0.2.3", | |
| "jsonwebtoken": "8.5.1", | |
| "moment": "2.26.0", | |
| "mongoose": "5.9.18", | |
| "multer": "1.4.2", | |
| "multer-s3": "2.9.0", | |
| "path": "0.12.7" | |
| }, | |
| "devDependencies": { | |
| "@babel/cli": "7.10.1", | |
| "@babel/core": "7.10.2", | |
| "@babel/node": "7.10.1", | |
| "@babel/polyfill": "7.10.1", | |
| "@babel/preset-env": "7.10.2", | |
| "babel-loader": "8.1.0", | |
| "morgan": "1.10.0", | |
| "nodemon": "2.0.4" | |
| } | |
| } ************************************************** 새로 폴더를 만드신후 이것을 그대로 복사하셔서 package.json에 붙여넣으시고, npm i 로 인스톨 하시기 바랍니다. | 
0

지우고 했는데, 안되더라고요. 패키지 설치 다시했는데도 안되요. 그래서 처음부터 강의를 다시따라하면서 dev쪽에만 설치 하고 실행해 봤는데 그것도 안됩니다.... 다른 방법이 없을까요?
0
지금 babel-node가 2개가설치되어 있는데 devDependencies에 있는게 제대로 된것이고, 그 위거는 잘못된것이라 지워주셔야 합니다
npm uninstall babel-node해주시기 바랍니다
0
0
"dependencies":{
"babel-node" : ^0.0.1-security -> 이 부분 지우시고, node_modules를 다시 설치해보시기 바랍니다. 다른 것이 설치되어 있네요.





