问题描述
在全球范围内安装一些npm软件包有时是邪恶的.我不想这样安装茉莉花:
Installing some npm packages globally is evil sometimes.I don't want to install jasmine like that:
npm install -g jasmine
如何在没有 -g 属性的情况下安装和使用茉莉花?
How can I install and use jasmine without -g attribute?
推荐答案
1)您需要启动一个npm项目.在向导的第5步(问题测试命令:),输入茉莉花
1) You need to init an npm project. On the 5-th step of the wizard (question test command:) input jasmine
npm init
1b)如果您之前已初始化npm项目,请确保在 package.json
1b) If you init npm project before, make sure you have these lines in your package.json
"scripts": {
"test": "jasmine"
},
2)安装茉莉花作为本地依赖项
2) Install jasmine as a local dependency
npm i --save-dev jasmine
3)初始化茉莉花(替代全局茉莉花初始化)
3) To init jasmine (alternative for global jasmine init)
npm test init
4)创建示例测试(替代全局茉莉花示例)
4) To create example tests (alternative for global jasmine examples)
npm test examples
5)运行测试(替代全局茉莉花)
5) To run tests (alternative for global jasmine)
npm test
-
P. S.保存您的全球环境:)
--
P. S. Save your global environment :)
这篇关于如何在本地安装和运行npm茉莉花的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!