【发布时间】:2019-01-02 22:37:58
【问题描述】:
我的 package.json 看起来像:
{
"name": "99-nodetest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "babel-node --presets env app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "latest"
}
}
我要运行的 js 脚本是 app.js。我无法直接使用 node app.js 运行它,因为 app.js 包含新的语言语法。
因此,我必须按照上面定义的启动脚本,使用 npm start 通过 babel 运行它。这里没有问题。
我的问题是如何在命令行中直接运行cmd,可以吗? 类似于:
npm run babel-node --presets env app.js
【问题讨论】:
-
仅供参考(并制作链接):上述问题与my question here