Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install and run npm jasmine locally

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?

like image 255
Sergiy Seletskyy Avatar asked Nov 14 '15 15:11

Sergiy Seletskyy


People also ask

How do I run npm locally?

You can do this by running npm link followed by the name of the local package. In this demo, the name of the package we want to test is jqq-package so you would run npm link jqq-package , but make sure to use the specific name of the package you are testing.

Does npm install locally?

Local Installation of Packages: Local packages are installed in the directory where you run npm install <package-name> and they are put in the node_modules folder under this directory. Example to illustrate How to install the package locally in the system.


1 Answers

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 :)

like image 173
Sergiy Seletskyy Avatar answered Oct 12 '22 14:10

Sergiy Seletskyy