{"id":582,"hash":"92a0ea7c28412e7f47a79742ae7e1bab739a059401c365124168b2b99304e0f6","pattern":"Babel command not found","full_message":"I have installed the babel-cli tool as explained by the Babel 'getting started' page.\n\nFrom a terminal inside my project folder:\n\nnpm install --save-dev babel-cli\n\nAfter this, there is a node_modules directory with a babel-cli folder, but there is no package.json created. npm also shows the following error:\n\nnpm WARN enoent ENOENT: no such file or directory, open '/Users/MyName/Sites/Tutorials/Babel2/package.json\n\nWhen trying to run babel, I get this:\n\nbabel src -d lib\n-bash: babel: command not found\n\nI have the latest version of nodejs/npm installed. I have run npm update -g, and I have edited my .bash_profile file to include:\n\nexport PATH=$PATH:/Users/MyName/npm/bin\nexport PATH=/usr/local/share/npm/bin:$PATH\n\nI have not experienced this with other npm tools such as browserify. Why is babel not recognized?","ecosystem":"npm","package_name":"npm","package_version":null,"solution":"There are two problems here. First, you need a package.json file. Telling npm to install without one will throw the npm WARN enoent ENOENT: no such file or directory error. In your project directory, run npm init to generate a package.json file for the project.\n\nSecond, local binaries probably aren't found because the local ./node_modules/.bin is not in $PATH. There are some solutions in How to use package installed locally in node_modules?, but it might be easier to just wrap your babel-cli commands in npm scripts. This works because npm run adds the output of npm bin (node_modules/.bin) to the PATH provided to scripts.\n\nHere's a stripped-down example package.json which returns the locally installed babel-cli version:\n\n{\n  \"scripts\": {\n    \"babel-version\": \"babel --version\"\n  },\n  \"devDependencies\": {\n    \"babel-cli\": \"^6.6.5\"\n  }\n}\n\nCall the script with this command: npm run babel-version.\n\nPutting scripts in package.json is quite useful but often overlooked. Much more in the docs: How npm handles the \"scripts\" field","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/34421513/babel-command-not-found","votes":92,"created_at":"2026-04-19T04:51:22.580362+00:00","updated_at":"2026-04-19T04:51:22.580362+00:00"}