Cant build app using npx grunt on Windows - node.js

On Windows 8.1 installed Node.js 12.16.
First I run "npm install grunt" in a root directory of project.
Installation passed succesfully, however with the following warnings:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#
1, but npm-shrinkwrap.json was generated for lockfileVersion#0. I'll try to do m
y best with it!
npm WARN deprecated minimatch#0.2.14: Please update to minimatch 3.0.2 or higher
to avoid a RegExp DoS issue
npm WARN deprecated coffee-script#1.3.3: CoffeeScript on NPM has moved to "coffe
escript" (no hyphen)
npm WARN deprecated minimatch#0.3.0: Please update to minimatch 3.0.2 or higher
to avoid a RegExp DoS issue
npm WARN platform-web#0.0.1 No repository field.
npm WARN platform-web#0.0.1 No license field.
npm WARN The package time-grunt is included as both a dev and production depende
ncy.
npm WARN The package object-assign is included as both a dev and production depe
ndency.
+ grunt#0.4.5
added 38 packages from 47 contributors and audited 54 packages in 3.026s
found 25 vulnerabilities (5 low, 6 moderate, 14 high)
run `npm audit fix` to fix them, or `npm audit` for details
Root directory containts grunt-folder (root_dir/grunt), in which Gruntfile.js and package.json files are located.
And this grunt-folder containts other grunt-folder (root_dir/grunt/grunt). This second grunt containts some js-files.
Then in "root_dir/grunt" I run "npx grunt". But the build aborted with the following log:
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-includes" not found. Is it installed?
>> Local Npm module "grunt-text-replace" not found. Is it installed?
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-contrib-cssmin" not found. Is it installed?
>> Local Npm module "grunt-file-creator" not found. Is it installed?
>> Local Npm module "grunt-war" not found. Is it installed?
>> Local Npm module "nexus-deployer" not found. Is it installed?
Warning: Task "clean:all" not found. Use --force to continue.
Aborted due to warnings.
package.json is
{
"name": "platform-web",
"version": "0.0.1",
"description": "Platform",
"devDependencies": {
"archiver": "^0.12.0",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "0.12.3",
"grunt-contrib-uglify": "^0.6.0",
"grunt-file-creator": "^0.1.3",
"grunt-includes": "^0.5.1",
"grunt-text-replace": "^0.4.0",
"grunt-war": "^0.5.1",
"nexus-deployer": "^0.1.8",
"object-assign": "^4.0.1",
"time-grunt": "^1.1.0"
},
"dependencies": {
"time-grunt": "^1.0.0",
"object-assign": "^4.0.1"
}
}
What am I doing wrong?
p.s.: root-folder is:

Following is only needed for older versions of grunt. New one install the bunstubbs correctly so you can still install grunt via npm and not globally.
Install grunt-cli. This will correctly pick up whichever version of grunt the project is running and execute it.
npm install grunt-cli --save-dev
In the package.json change dev script to
"scripts": {
"start": "npx grunt-cli"
}
then run
npm run start

Related

Upgrading Angular solution from v11.0.5 to v15.0.5

TL;DR: What is the fastest way to upgrade a legacy Angular (eg v11) to the latest version (eg v15)?
I have an Angular 11 solution which has this packages.json file:
{
"name": "my-first-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^11.0.5",
"#angular/common": "^11.0.5",
"#angular/compiler": "^11.0.5",
"#angular/core": "^11.0.5",
"#angular/forms": "^11.0.5",
"#angular/platform-browser": "^11.0.5",
"#angular/platform-browser-dynamic": "^11.0.5",
"#angular/router": "^11.0.5",
"bootstrap": "3.3.7",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.0.0",
"tslib": "^2.0.3",
"zone.js": "^0.10.3"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.1100.4",
"#angular/cli": "^11.0.4",
"#angular/compiler-cli": "^11.0.5",
"#types/jasmine": "~3.6.0",
"#types/jasminewd2": "~2.0.3",
"#types/node": "^12.19.9",
"codelyzer": "^6.0.1",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}
npm install in the solution folder produces this:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-first-app#0.0.0
npm ERR! Found: jasmine-core#3.6.0
npm ERR! node_modules/jasmine-core
npm ERR! dev jasmine-core#"~3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core#">=3.8" from karma-jasmine-html-reporter#1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR! dev karma-jasmine-html-reporter#"^1.5.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\xxx\AppData\Local\npm-cache\_logs\2023-01-25T20_36_55_645Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xxx\AppData\Local\npm-cache\_logs\2023-01-25T20_36_55_645Z-debug-0.log
I then run npm install --legacy-peer-deps, which produces a lot of WARN statements and then shows this:
added 1597 packages, and audited 1598 packages in 1m
118 packages are looking for funding
run `npm fund` for details
27 vulnerabilities (5 moderate, 21 high, 1 critical)
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
So, I run npm audit fix --force which produces this:
added 143 packages, removed 694 packages, changed 122 packages, and audited 1047 packages in 20s
86 packages are looking for funding
run `npm fund` for details
# npm audit report
minimatch <3.0.5
Severity: high
minimatch ReDoS vulnerability - https://github.com/advisories/GHSA-f8q6-p94x-37v3
fix available via `npm audit fix`
node_modules/minimatch
1 high severity vulnerability
To address all issues, run:
npm audit fix
So, I run npm audit fix --force again, and it shows this:
removed 1 package, changed 1 package, and audited 1046 packages in 3s
86 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Now, if I run ng serve I get this:
Your global Angular CLI version (15.0.5) is greater than your local version (11.1.2). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
This version of CLI is only compatible with Angular versions ^15.0.0,
but Angular version 11.2.14 was found instead.
Please visit the link below to find instructions on how to update Angular.
https://update.angular.io/
I visit https://update.angular.io/ and select from v11 to v12, as it also states
You can't run ng update to update Angular applications more than one
major version at a time.
So, from https://update.angular.io/?v=11.0-12.0 I run ng update #angular/core#12 #angular/cli#12, which produces:
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 12.2.18 to perform the update.
√ Packages successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 31 dependencies.
Fetching dependency metadata from registry...
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "#angular/compiler-cli" (requires "^15.0.0" (extended), would install "12.2.17").
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=4.8.2 <5.0", would install "4.3.5").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
See "C:\Users\xxx\AppData\Local\Temp\ng-7soZ7i\angular-errors.log" for further details.
So I run ng update #angular/core#12 #angular/cli#12 --force which produces a lot of output, but appears to work.
Next, I moved to https://update.angular.io/?v=12.0-13.0 which states I should run ng update #angular/core#13 #angular/cli#13 and produces:
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 13.3.10 to perform the update.
√ Packages successfully installed.
Using package manager: 'npm'
Collecting installed dependencies...
Found 31 dependencies.
Fetching dependency metadata from registry...
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "#angular/compiler-cli" (requires "^15.0.0" (extended), would install "13.3.12").
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "typescript" (requires ">=4.8.2 <5.0", would install "4.6.4").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
See "C:\Users\xxx\AppData\Local\Temp\ng-p47IAP\angular-errors.log" for further details.
So I run it like this: ng update #angular/core#13 #angular/cli#13 --force which also produces a lot of output but finally appears to complete successfully.
This moves me to https://update.angular.io/?v=13.0-14.0 which states I should run ng update #angular/core#14 #angular/cli#14. I see this:
The installed Angular CLI version is outdated.
Installing a temporary Angular CLI versioned 14.2.10 to perform the update.
√ Packages successfully installed.
Using package manager: npm
Collecting installed dependencies...
Found 31 dependencies.
Fetching dependency metadata from registry...
Package "#angular-devkit/build-angular" has an incompatible peer dependency to "#angular/compiler-cli" (requires "^15.0.0" (extended), would install "14.2.12").
× Migration failed: Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.
See "C:\Users\xxx\AppData\Local\Temp\ng-wQ5M5Z\angular-errors.log" for further details.
So I run ng update #angular/core#14 #angular/cli#14 --force which, again, appears to complete successfully.
This leads me to https://update.angular.io/?v=14.0-15.0 and running the command ng update #angular/core#15 #angular/cli#15 which appears to complete, as well - fortunately, this time, without the need for --force.
Running ng serve works.
Is this the best way to upgrade a legacy Angular project to the latest version?
Yes, the ng update command is the recommended path to update angular applications.
With the latest CLI Versions, you can update only one version at a time (in the past, you could bump two or more versions at once). The idea behind this is to be able to run all the needed migrations when updating to a newer version without the risk of conflicts. The CLI runs the migrations for you.
The errors you got, like:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-first-app#0.0.0
npm ERR! Found: jasmine-core#3.6.0
npm ERR! node_modules/jasmine-core
npm ERR! dev jasmine-core#"~3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer jasmine-core#">=3.8" from karma-jasmine-html-reporter#1.7.0
npm ERR! node_modules/karma-jasmine-html-reporter
npm ERR! dev karma-jasmine-html-reporter#"^1.5.4" from the root project
Are not related to Angular, but to npm (I guess you are using npm 7+). Newer npm versions will check that peer dependencies versions are respected and throw an error in case of a wrong version (as you are getting). From npm 7 release docs:
npm 7 will block installations if an upstream dependency conflict is
present that cannot be automatically resolved.
You have the option to retry with --force to bypass the conflict or
--legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).
In general, I would advise avoiding using --force while updating your dependencies and trying to find the right combination of versions between the libraries.

What could cause an error related to npm not being able to find a file? No contents in my node_modules subfolder. Why is that?

I'm trying to run npm install in the angular project folder I got from ASP.NET Boilerplate and I'm getting an error that is "related to npm not being able to find a file."
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install
npm WARN deprecated #types/moment#2.13.0: This is a stub types definition for Moment (https://github.com/moment/moment). Moment provides its own type definitions, so you don't need #types/moment installed!
npm WARN codelyzer#3.2.2 requires a peer of #angular/compiler#^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN codelyzer#3.2.2 requires a peer of #angular/core#^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\fsevents-8cc0601e\node_modules\are-we-there-yet' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\are-we-there-yet-cedb4a6a'
npm ERR! path D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\typescript
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Jack\AppData\Roaming\npm-cache\_logs\2018-03-21T19_33_18_250Z-debug.log
I can clearly see that this is happening because my node_modules subfolder contains only a single folder structure with no files within it. That structure is:
node_modules\#angular-devkit\build-optimizer\node_modules
I have node 8.9.4, npm 5.6.0, and angular-CLI 1.5.0 installed as well as typescript 2.0.0. The latter two packages have been installed globally.
Here are the package.json file contents:
{
"name": "MyProject",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 4200",
"hmr": "ng serve --host 0.0.0.0 --port 4200 4201 --hmr -e=hmr",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.0.3",
"#angular/common": "^5.0.3",
"#angular/compiler": "^5.0.3",
"#angular/core": "^5.0.3",
"#angular/forms": "^5.0.3",
"#angular/http": "^5.0.3",
"#angular/platform-browser": "^5.0.3",
"#angular/platform-browser-dynamic": "^5.0.3",
"#angular/router": "^5.0.3",
"#aspnet/signalr": "1.0.0-preview1-28189",
"#types/bootstrap": "^3.3.33",
"#types/jquery": "^3.2.12",
"#types/jquery.blockui": "0.0.28",
"#types/jquery.validation": "^1.16.3",
"#types/lodash": "^4.14.62",
"#types/moment": "^2.13.0",
"#types/moment-timezone": "^0.2.34",
"#types/signalr": "^2.2.33",
"#types/toastr": "^2.1.33",
"abp-ng2-module": "^1.3.0",
"abp-web-resources": "^3.3.0",
"animate.css": "^3.5.2",
"block-ui": "^2.70.1",
"bootstrap": "^3.3.7",
"bootstrap-select": "^1.12.2",
"chart.js": "^2.6.0",
"core-js": "^2.4.1",
"famfamfam-flags": "^1.0.0",
"flot": "^0.8.0-alpha",
"font-awesome": "^4.7.0",
"jquery": "^3.1.1",
"jquery-countto": "^1.2.0",
"jquery-migrate": "^3.0.0",
"jquery-slimscroll": "^1.3.8",
"jquery-sparkline": "^2.4.0",
"js-cookie": "^2.1.4",
"lodash": "^4.17.4",
"moment": "^2.18.1",
"moment-timezone": "^0.5.13",
"morris.js": "^0.5.0",
"ngx-bootstrap": "^2.0.2",
"ngx-pagination": "^3.0.3",
"node-waves": "^0.7.5",
"push.js": "1.0.4",
"raphael": "^2.2.7",
"rxjs": "^5.5.2",
"signalr": "^2.2.1",
"simple-line-icons": "^2.4.1",
"spin.js": "^2.3.2",
"sweetalert": "^2.0.8",
"toastr": "^2.1.2",
"ts-helpers": "^1.1.2",
"web-animations-js": "^2.3.1",
"zone.js": "0.8.18"
},
"devDependencies": {
"#angular/cli": "^1.5.4",
"#angular/compiler-cli": "^5.0.3",
"#angularclass/hmr": "^2.1.3",
"#types/jasmine": "^2.5.38",
"#types/node": "^8.0.27",
"codelyzer": "^3.1.2",
"jasmine-core": "^2.5.2",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^1.4.1",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"nswag": "^11.12.7",
"protractor": "^5.1.1",
"ts-node": "^3.3.0",
"tslint": "^5.7.0",
"typescript": "2.4.2"
}
}
When I run npm install, I can see the packages being downloaded into the .staging folder. At the point that the finalize command is run (see the log below), I can see that the package folders are being consolidated and copied somewhere, but that somewhere does not appear to be my node_modules subfolder other than the first set of subfolders as I have shown above. When the npm install completes, the .staging folder is deleted and all that I have left is that partial folder structure.
Admittedly I am new to Node development - I usually work on our ASP.NET Web API backends. I'm trying to get my development environment in sync with our front-end developer's development environment. I have spent most of the day looking for a solution. I've tried uninstalling and reinstalling Node. I've tried different versions that match our front-end developer's environment. I've tried using the latest versions of angular-CLI and typescript and have fallen back to the versions I reference above in hopes that the "requires a peer" warnings would be resolved. I have searched for similar answers on this site. The closest one I have found remains unanswered.
Here is the end of the "complete log" referenced in the npm error output:
19577 silly saveTree | `-- tsutils#2.22.2
19577 silly saveTree +-- typescript#2.4.2
19577 silly saveTree +-- web-animations-js#2.3.1
19577 silly saveTree `-- zone.js#0.8.18
19578 warn codelyzer#3.2.2 requires a peer of #angular/compiler#^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
19579 warn codelyzer#3.2.2 requires a peer of #angular/core#^2.3.1 || >=4.0.0-beta <5.0.0 but none is installed. You must install peer dependencies yourself.
19580 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\fsevents):
19581 warn optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\fsevents-8cc0601e\node_modules\are-we-there-yet' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\.staging\are-we-there-yet-cedb4a6a'
19582 verbose optional SKIPPING OPTIONAL DEPENDENCY:
19582 verbose optional Please try running this command again as root/Administrator.
19583 verbose stack Error: ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
19584 verbose cwd D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular
19585 verbose Windows_NT 10.0.16299
19586 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
19587 verbose node v8.9.4
19588 verbose npm v5.6.0
19589 error path D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\typescript
19590 error code ENOENT
19591 error errno -4058
19592 error syscall rename
19593 error enoent ENOENT: no such file or directory, rename 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\typescript' -> 'D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular\node_modules\#angular-devkit\build-optimizer\node_modules\.typescript.DELETE'
19594 error enoent This is related to npm not being able to find a file.
19595 verbose exit [ -4058, true ]
Please advise.
The following steps work for me:
npm cache clean -f
rm -rf node_modules
npm i
It might be related to corruption in Angular Packages or incompatibility of packages.
Please follow the below steps to solve the issue.
Delete node_modules folder manually.
Install Node ( https://nodejs.org/en/download ).
Install Yarn ( https://yarnpkg.com/en/docs/install ).
Open command prompt , go to path angular folder and run Yarn.
Run angular\nswag\refresh.bat.
Run npm start from the angular folder.
Update
ASP.NET Boilerplate suggests here to use yarn because npm has some problems. It is slow and can not consistently resolve dependencies, yarn solves those problems and it is compatible to npm as well.
I had the SAME issue today and it was driving me nuts!!! What I had done was upgrade to node 8.10 and upgrade my NPM to the latest I uninstalled angular CLI
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
I then verified my Cache from NPM if it wasn't up to date I cleaned it and ran the install again
if npm version is < 5 then use npm cache clean --force
npm install -g #angular/cli#latest
and created a new project file and create a new angular project.
Try the following steps:
1. Make sure you have the latest npm (npm install -g npm).
2. Add an exception to your antivirus to ignore the node_modules folder in your project.
3. $ rm -rf node_modules package-lock.json .
4. $ npm install
Following what #viveknuna suggested, I upgraded to the latest version of node.js and npm using the downloaded installer. I also installed the latest version of yarn using a downloaded installer. Then, as you can see below, I upgraded angular-cli and typescript. Here's what that process looked like:
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install -g #angular/cli#latest
C:\Users\Jack\AppData\Roaming\npm\ng -> C:\Users\Jack\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\#angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ #angular/cli#1.7.3
added 75 packages, removed 166 packages, updated 61 packages and moved 24 packages in 29.084s
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm install -g typescript
C:\Users\Jack\AppData\Roaming\npm\tsserver -> C:\Users\Jack\AppData\Roaming\npm\node_modules\typescript\bin\tsserver
C:\Users\Jack\AppData\Roaming\npm\tsc -> C:\Users\Jack\AppData\Roaming\npm\node_modules\typescript\bin\tsc
+ typescript#2.7.2
updated 1 package in 2.427s
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>node -v
v8.10.0
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm -v
5.6.0
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>yarn --version
1.5.1
Thereafter, I ran yarn and npm start in my angular folder and all appears to be well. Here's what that looked like:
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>yarn
yarn install v1.5.1
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.1.3: The platform "win32" is incompatible with this module.
info "fsevents#1.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "#angular/cli > #schematics/angular#0.1.10" has incorrect peer dependency "#angular-devkit/schematics#0.0.40".
warning "#angular/cli > #angular-devkit/schematics > #schematics/schematics#0.0.10" has incorrect peer dependency "#angular-devkit/schematics#0.0.40".
warning " > codelyzer#3.2.2" has incorrect peer dependency "#angular/compiler#^2.3.1 || >=4.0.0-beta <5.0.0".
warning " > codelyzer#3.2.2" has incorrect peer dependency "#angular/core#^2.3.1 || >=4.0.0-beta <5.0.0".
[4/4] Building fresh packages...
Done in 232.79s.
D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular>npm start
> MyProject#0.0.0 start D:\Dev\AspNetBoilerplate\MyProject\3.5.0\angular
> ng serve --host 0.0.0.0 --port 4200
** NG Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **
Date: 2018-03-22T13:17:28.935Z
Hash: 8f226b6fa069b7c201ea
Time: 22494ms
chunk {account.module} account.module.chunk.js () 129 kB [rendered]
chunk {app.module} app.module.chunk.js () 497 kB [rendered]
chunk {common} common.chunk.js (common) 1.46 MB [rendered]
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 515 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.1 MB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 1.53 MB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 15.1 MB [initial] [rendered]
webpack: Compiled successfully.
If it happens, then it means you have to upgrade your node.js. Simply uninstall your current node from your pc or mac and download the latest version from https://nodejs.org/en/
In my case
npm cache clean --force
Also not working so, I use
yarn
First, install yarn globally
npm i -g yarn
Then instead of "npm start", I do,
yarn add
This works for me.
I had faced the same problem. After google search I found this solution:
'git' is not recognized as an internal or external command
Check this out hope your problem will be solved
In my case, this error happened with a new project.
none of the proposed solutions here worked, so I simply reinstalled all the packages and started working correctly.
In my case I tried to run npm i firebase#7.8.2 and got the error because the dev server was running in another terminal on vsc. Hit ctrl+c, y to stop it in that terminal, and then installation works.
In my case, I had to create a new app, reinstall my node packages, and copy my src document over. That worked.
Change your firebase.json from:
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
To:
{
"functions": {
}
}
I was trying to do it in a folder inside dropbox. I think dropbox was locking files as it uploaded them or something and that didn't work. It would fail in different places.

npm install -g download all the dependencies again

I have package.json file, that contains 10 dependencies,
Every time I do npm install -g,all the dependencies are downloaded again, and this takes a long time.
Is there a way to take the existing dependencies from the local node_modules directory ?
This is my package.json dependencies:
"dependencies": {
"body-parser": "~1.16.0",
"colors": "^1.1.2",
"console-stamp": "^0.2.5",
"cookie-parser": "~1.4.3",
"dateformat": "^2.0.0",
"debug": "~2.6.0",
"express": "~4.14.1",
"ip": "^1.1.5",
"jade": "~1.11.0",
"lodash": "^4.17.4",
"morgan": "~1.7.0",
"nodemon": "^1.11.0",
"promise": "^8.0.1",
"rand-token": "^0.3.0",
"random-date-generator": "^1.0.2",
"restify": "^4.3.0",
"restify-cookies": "^0.2.2",
"serve-favicon": "~2.3.2"
}
Thanks,
npm install -g installs the current package context (i.e, the current working directory) as a global package. You do not need this for installing the project dependencies. Instead you can use npm install which will install/update dependencies in node_modules folder. By default, npm install will install all modules listed as dependencies in package.json and they do not install all dependencies every time and will only update when a change has been made to package.json or the node_modules folder is cleared out.
use npm install -g option to install packages globally like cordova, gulp, yeoman etc where you need them to be available throughout multiple projects.
Conceptually, the input to npm-install is a package.json, while its output is a fully-formed node_modules tree.
This shouldn't be an issue because npm uses the cache. It returns 304 if you have already installed the module, you can check it by applying --verbose with npm install command if given it's the same version of the dependency.
What I mean is:
$ npm install express
npm http fetch GET http://registry.npmjs.org/express
npm http fetch GET 200 http://registry.npmjs.org/express
at last, it shows:
++ express#4.16.2
added 49 packages in 12.547s
If you run it again then you will see
$ npm install express
npm http fetch GET http://registry.npmjs.org/express 408ms (from cache)
npm http fetch GET 304 http://registry.npmjs.org/express 408ms (from cache)
at last, it shows:
skipping write for package.json because there were no changes
++ express#4.16.2
updated 1 package in 4.11s
It hits the cache and won't download it again.
When running npm install for a second time on a project then it will not download it again only npm will check the first level of modules to ensure they're installed.
but not traverse the dependency tree to ensure all sub-module dependencies are installed. You can run npm outdated to check if modules are missing but npm won't install them for you.
npm update express updates the express module and its dependencies. So updates are when you already have the module and wish to get the new version. the update will always update to the latest version, regardless of package.json, while npm install will respect the version given in package.json.

Npm rebuild node-sass fails

I have an old project that has a grunt as build tool. I have installed the project dependencies and grunt cli. This is the package.json file:
{
"name": "",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-sass": "^1.0.0",
"node-sass": "^3.3.3"
}
}
On trying to run grunt I got an error that I need to run npm rebuild node-sass, but I got a new error then:
npm ERR! Failed at the node-sass#3.4.2 postinstall script 'node
scripts/build.js'. npm ERR! Make sure you have the latest version of
node.js and npm installed. npm ERR! If you do, this is most likely a
problem with the node-sass package, npm ERR! not with npm itself.
I have even tried with running the command with the --force flag.
But that didn't work either, how can I fix this?

Docker npm install fails

I'm trying to build an ASP.Net 5.0 web app using Docker, but it fails when it reaches the npm install step, with:
Step 14 : RUN npm install
---> Running in 15c191d1ca1d
npm WARN deprecated gulp-karma#0.0.4: Please use Karma directly: https://github.com/karma-runner/gulp-karma
npm WARN deprecated graceful-fs#3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated lodash#1.0.2: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^4.0.0.
npm WARN deprecated graceful-fs#1.2.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated graceful-fs#2.0.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated npmconf#2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN prefer global typescript#1.5.3 should be installed with -g
npm WARN prefer global node-gyp#3.3.1 should be installed with -g
> node-sass#3.4.2 install /app/src/CDWebDesigner/node_modules/node-sass
> node scripts/install.js
Binary downloaded and installed at /app/src/CDWebDesigner/node_modules/node-sass/vendor/linux-x64-11/binding.node
> spawn-sync#1.0.15 postinstall /app/src/CDWebDesigner/node_modules/spawn-sync
> node postinstall
Installing native dependencies (this may take up to a minute)
> node-sass#3.4.2 postinstall /app/src/CDWebDesigner/node_modules/node-sass
> node scripts/build.js
The command 'npm install' returned a non-zero code: 1
ERROR: Build failed with: exit status 1
I can't see any errors here that explain why it's failing, only WARNings. I assume this must either be a problem with the npm installation or the modules it's trying to install. loadash#1.0.2 says it will fail on newer npm installs, but I don't know how to update this, or which of the dependencies is pulling this in.
Dockerfile
FROM microsoft/aspnet:1.0.0-rc1-final
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs
RUN apt-get install bzip2
RUN curl -L https://npmjs.org/install.sh | sh
# Install bower
RUN npm install -g bower
# Install Gulp
RUN npm install -g gulp
# Install Git (for bower)
RUN apt-get -y install git
COPY . /app
WORKDIR /app
RUN ["dnu", "restore"]
WORKDIR ./src/myapp
RUN ["npm", "install"]
RUN ["bower", "install", "--allow-root"]
RUN ["gulp", "prod"]
EXPOSE 5000
CMD dnx kestrel
package.json
{
"name": "ASP.NET",
"version": "0.0.0",
"devDependencies": {
"gulp": "3.8.11",
"gulp-concat": "2.5.2",
"gulp-cssmin": "0.1.7",
"gulp-uglify": "1.2.0",
"del": "^2.2.0",
"gulp-sass": "^2.0.4",
"gulp-typescript": "~2.8.0",
"main-bower-files": "~2.9.0",
"gulp-sourcemaps": "~1.5.2",
"mocha": "~2.2.5",
"gulp-mocha": "~2.1.3",
"karma-chai": "~0.1.0",
"chai": "~3.2.0",
"karma": "~0.13.9",
"karma-jasmine": "~0.3.6",
"karma-phantomjs-launcher": "~0.2.1",
"karma-spec-reporter": "~0.0.20",
"gulp-karma": "^0.0.4",
"gulp-js-obfuscator": "~1.0.0",
"gulp-order": "^1.1.1",
"gulp-debug": "^2.1.2"
}
}
Not sure, but 1st: you can try install with sudo npm install, and 2nd you can try to install on this machine node-gyp and pyton 2.7 . If module during installation require compilation of node extension, then you will need these two things.
3rd. How we usually debug: Create an image on the state before failing command. run container with interactive shell (with -it). login inside. And run npm install by hands. See and understand output there. Fix.

Resources