Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running a command after install dependencies using npm install

I have a package.json file like this

{
  "name": "E2E",
  "version": "1.0.0",
  "description": "AngularJS E2E testing",
  "main": "conf.js",
  "scripts": {
    "postinstall": "node_modules/protractor/bin/webdriver-manager update",
    "test": "echo \"Error: no test specified\" && exit 1"
  },  
  "license": "ISC",
  "devDependencies": {
    "protractor": "^2.2.0"
  }
}

when running command npm install after protractor is installed its throwing error

node_modules/protractor/bin/webdriver-manager update
'node_modules' is not recognized as an internal or external command, operable program or batch file
like image 793
coure2011 Avatar asked Sep 15 '15 11:09

coure2011


People also ask

How do I run a script after npm install?

You can easily run scripts using npm by adding them to the "scripts" field in package. json and run them with npm run <script-name> . Run npm run to see available scripts. Binaries of locally install packages are made available in the PATH , so you can run them by name instead of pointing to node_modules/.

What happens when you execute the npm command npm install?

Description. This command installs a package, and any packages that it depends on. If the package has a package-lock or shrinkwrap file, the installation of dependencies will be driven by that, with an npm-shrinkwrap.

Where should I run npm install command?

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.


2 Answers

Ok found the fix, I need to run it as node command like this

"postinstall": "node node_modules/protractor/bin/webdriver-manager update",
like image 175
coure2011 Avatar answered Oct 05 '22 22:10

coure2011


Try prepending the path to executable with a dot followed by a slash:

 ./node_modules/protractor/bin/webdriver-manager update
like image 40
Pavlo Avatar answered Oct 05 '22 22:10

Pavlo