Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm post-install typings not working correctly

I have the following packages.json:

{
"name": "shopping-assistant-angular",
"version": "1.0.0",
"scripts": {
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",    
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install" 
},
"license": "ISC",
"dependencies": {
    "angular2": "2.0.0-beta.7",
    "systemjs": "0.19.23",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.14"
},
"devDependencies": {
    "bower": "^1.7.7",
    "concurrently": "^1.0.0",
    "grunt": "^0.4.5",
    "grunt-chrome-manifest": "^0.3.0",
    "grunt-contrib-clean": "^1.0.0",
    "grunt-contrib-concat": "^0.5.1",
    "grunt-contrib-copy": "^0.8.2",
    "grunt-contrib-cssmin": "^0.14.0",
    "grunt-contrib-htmlmin": "^0.6.0",
    "grunt-contrib-uglify": "^0.11.1",
    "grunt-filerev": "^2.3.1",
    "grunt-ts": "^5.3.2",
    "grunt-usemin": "^3.1.1",
    "lite-server": "^2.0.1",
    "load-grunt-tasks": "^3.4.0",
    "typescript": "1.7.5",
    "typings": "^0.6.8"
}
}

when I run npm install in my directory I get an error: 'typings' is not recognized as an internal or external command, operable program or batch file.

In the Angular 2 quick-start guide they use the following packages.json:

{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" ",    
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install" 
},
"license": "ISC",
"dependencies": {
    "angular2": "2.0.0-beta.7",
    "systemjs": "0.19.22",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.2",
    "zone.js": "0.5.15"
},
"devDependencies": {
    "concurrently": "^2.0.0",
    "lite-server": "^2.1.0",
    "typescript": "^1.7.5",
    "typings":"^0.6.8"
}
}

Which successfully runs "typings install" after all of the packages are done install.

Not sure why running these very similar packages.json files are resulting in completely different outcomes.

like image 945
Gabe O'Leary Avatar asked Feb 26 '16 22:02

Gabe O'Leary


People also ask

How to only run the postinstall script if NPM install was not run?

NPM sets an environment variable to "true" when install is run with --production. To only run the postinstall script if npm install was not run with --production, use the following code. "postinstall": "if [ -z "$npm_config_production" ]; then node_modules/gulp/bin/gulp.js first-run; fi",

Why is NPM install not working on my Device?

The npm install command may fail to work because of many reasons. When the command doesn’t work, you need to check the output first and see what specific error you have. Try a Google search to fix the issue.

What are some things I should not do with npm?

Don't prefix your script commands with "sudo". If root permissions are required for some reason, then it'll fail with that error, and the user will sudo the npm command in question. Don't use install.

What happened to the NPM prepublish script?

Newer npm (& Yarn) versions include support for the prepare script that is run after each install run but only in development mode. Also, the prepublish is deprecated.


2 Answers

In ionic 2 , I faced same issue on window 10 then I tried npm install typings -g , after installation I tried typings command and wow it worked, I was working with ionic 2 with socket.io and I needed to run
typings install dt~socket.io-client --save --global , now it is working.

Hope this will help you.

like image 104
user3563484 Avatar answered Oct 14 '22 14:10

user3563484


Gabe O'Leary is right (see comment), first try to install typings globally npm install typings -g if you are using a mac you might need to use the sudo command sudo npm install typings -g

like image 33
pearpages Avatar answered Oct 14 '22 15:10

pearpages