Reputation: 58795
I'm trying to run babel
as a build step in my project, but it doesn't seem to work.
My package.json
looks like this:
{
"name": "module-name",
"version": "1.0.0",
"description": "My Module",
"main": "build/index.js",
"scripts": {
"test": "karma start",
"build": "./node_modules/.bin/babel src -d build"
},
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.23.0",
"babel-preset-env": "^1.1.8"
}
}
And .babelrc
, in the same directory, looks like this:
{
"presets": ["env"]
}
The command npm test
works fine and the Karma tests run. But when I use npm build --verbose
, I just get the following output:
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Users\\Peter\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'build',
npm verb cli '--verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb exit [ 0, true ]
npm info ok
But the Babel command did not run and the build directory is not created. However, running the command ./node_modules/.bin/babel src -d build
directly from the command line works perfectly.
Any ideas what might be causing the problem?
Upvotes: 1
Views: 4078
Reputation: 67316
npm test
is a built in npm command, but your build
command is not built in.
For npm commands that are not built in you need to run
them:
npm run build
Upvotes: 5