How to install and run npm jasmine locally

删除回忆录丶 提交于 2019-12-12 08:27:10

问题


Installing some npm packages globally is evil sometimes. I don't want to install jasmine like that:

npm install -g jasmine

How can I install and use jasmine without -g attribute?


回答1:


1) You need to init an npm project. On the 5-th step of the wizard (question test command:) input jasmine

npm init

1b) If you init npm project before, make sure you have these lines in your package.json

"scripts": {
  "test": "jasmine"
},

2) Install jasmine as a local dependency

npm i --save-dev jasmine

3) To init jasmine (alternative for global jasmine init)

npm test init

4) To create example tests (alternative for global jasmine examples)

npm test examples

5) To run tests (alternative for global jasmine)

npm test 

--
P. S. Save your global environment :)



来源:https://stackoverflow.com/questions/33709724/how-to-install-and-run-npm-jasmine-locally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!