我试图在我的项目中运行babel
作为构建步骤,但它似乎无法正常工作。
我的package.json
看起来像这样:
{
"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"
}
}
.babelrc
位于同一目录中,如下所示:
{
"presets": ["env"]
}
命令npm test
正常工作,并且Karma测试运行。但是当我使用npm build --verbose
时,我只得到以下输出:
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 npm@3.10.2
npm info using node@v6.9.3
npm verb exit [ 0, true ]
npm info ok
但是Babel命令没有运行,并且没有创建构建目录。但是,直接从命令行运行命令./node_modules/.bin/babel src -d build
可以很好地工作。
可能导致问题的任何想法?