最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Run Node.js command from package.json - Stack Overflow

programmeradmin1浏览0评论

Can i run this mand node.js from package.json ?

"browserify file.js -o bundle.js" 

if i can how i can do this and how to execute it without using mand prompt?

Can i run this mand node.js from package.json ?

"browserify file.js -o bundle.js" 

if i can how i can do this and how to execute it without using mand prompt?

Share Improve this question asked Dec 16, 2015 at 21:22 ameniameni 3932 gold badges9 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

npm gives you the ability to run aliased mands that you can store in your package.json file. Two basics are npm test and npm start, which respectively test and start your application (if you provide the mands that would do those things).

You can put your aliased mands in a nested object w/in the scripts property. To run mands that aren't either start or test, you have to use npm run <mand alias>. So, you could do npm run bundle.

"scripts": {
   "test": "some test mand",
   "start": "some start mand",
   "bundle": "browserify file.js -o bundle.js"
}

Also, to clarify, you can't execute code from/in a JSON file, JSON is just a data interchange format.

Hope that helps!

发布评论

评论列表(0)

  1. 暂无评论