Angular cli not working in Git Bash terminal on Windows - node.js

I've been trying to install the Angular CLI via npm. My current node version is v11.2.0 and my npm version is 6.4.1.
After running the command npm install -g #angular/cli I get this output:
C:\Users\Mark O'Hare\AppData\Roaming\npm\ng -> C:\Users\Mark O'Hare\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules\#angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
and when I try ng -v I get this error message:
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module 'C:\c\Users\Mark O'Hare\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:775:12)
at startup (internal/bootstrap/node.js:300:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:826:3)
Things I've tried so far:
Uninstalling angular via npm and reinstalling
Uninstalling node.js and deleting npm folders, restarting machine and reinstalling
Creating alias's for 'ng' with the path to the ng file in the npm node_modules folder
So far none of these have worked. Can anyone help or suggest a workaround?

I guess the problem lies within the user folder Mark O'Hare:
Error: Cannot find module 'C:\c\Users\Mark O'Hare\AppData\Roaming\npm\node_modules\#angular\cli\bin\ng' --> it reads the string until the second apostrophe, which is inside O'Hare, ultimately reading the folder as
C:\c\Users\Mark O

You can also try to use linux subsystem.
I would recommend it as it's easier to make JS env working.
https://learn.microsoft.com/en-us/windows/wsl/install-win10

i think folder name Mark O'Hare is the issue.
Instead of global installation try to install it in local and try to run the cli

Related

Installing node-sass fails on Ubuntu 18.04

I have a simple next.js project, which I created following their tutorial. It builds and runs well on my Windows development machine.
I want to deploy it on Ubuntu 18.04.02 LTS but when I clone the git project and run npm install it fails to install node-sass with the following error message:
> node-sass#4.12.0 install /var/www/example.com/beta/node_modules/node-sass
> node scripts/install.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module '/var/www/example.com/beta/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.12.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.12.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: ...
Here is a gist of the log file. See the last few lines for the error (I have included the whole file in case there is other information that is useful).
My NodeJS version is 10.15.3 and my NPM version is 6.4.1. I am not sure how to run next.js project on Ubuntu.
Apparently, I needed to install it with --unsafe-perms flag:
npm install --unsafe-perms
No explanation onto why it needs this and the unsafe word is not recommended by many.
In addition, the folder permissions needed to be in such a way that the script can create folders. I had to create a folder as me, clone the repo there, run the npm install --unsafe-perms, and then set the permissions as of a production web server.
For reference see here.
Try installing it manually, prior to installing all of the other packages - there might be some package dependency issue.
npm install node-sass#4.12.0 && npm install
This module has striction about node versions, as below:
solution is: specify the module version when you install it.
P.S. Other approach:
if you just want to use scss/sass, use this module:
npm install sass sass-loader
this does NOT work for: node 16, ubuntu 18
npm install --unsafe-perms
for node 14, ubuntu 18 , I can install it:
npm install node-sass

npm install error (code EBADPLATFORM)

When I tried to run npm install, it gave me this error:
$ npm install
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents#1.1.3: wanted
{"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Aroma\AppData\Roaming\npm-cache\_logs\2018-03-
25T11_33_58_338Z-debug.log
The node version:
$node -v
v8.10.0
I tried every thing, like:
npm cache clear
npm cache verify
npm i -g npm#latest
I even tried uninstalling and reinstalling Nodejs again but still get the same error.
I had the same issue, deleting my "package-lock.json" and re-running npm install worked
For those having issue on render.com
remove package-lock.json from your repo or add to gitignore
then run the build command npm install ; npm run build using the build from last comment option on render.com dashboard
Error is indicating that you are installing fsevents module in other OS rather than Mac
fsevents module only works for Mac Operting system
This worked effortless for me on Windows:
Go to project's "package-lock.json" file.
Press "Ctrl+F" (to enable keyword search).
Type "darwin".
Wherever it says "darwin" in the file, change that to "win32".
Restart your VS Code and you should be good to go.
Add following to your project's package.json
"optionalDependencies": {
"fsevents": "*"
},
and then install with --no-optional
Same npm install error (code EBADPLATFORM):
I had forced fsevents onto my windows machine npm i -f fsevents...
npm responded "I hope you know what your doing".
To repair, needed to
delete package-lock.json
delete line: fsevents#2.3.2 in package.json (your suffix may differ)
re-ran npm install
Remove "fsevents": "version", on package.json if you try to install on Windows.
I'm developing on Mac. I deleted "os": [ "darwin" ] from package.lock.json, ran the build, deployed to my Google Cloud App Engine project, and it finally worked.
Source: belykh's comment (Nothing posted in any of the other answers helped me.)
The error says it all:
Unsupported platform for fsevents#1.1.3:
wanted {"os":"darwin","arch":"any"}
(current: {"os":"win32","arch":"x64"})
This module doesn't support Windows, you can't use it if you're on Windows.
I think In your Project Folder First Delete package.lock.json and then try:
npm install
This is Works For Me.
I had this same issue on my dev machine (Win 10 x64). I had no intention of running or using fsevents locally. I just needed to upgrade my local copy of fsevents, to resolve a vulnerability. Running with the -f option solved it:
npm install fsevents#1.2.9 -f
Note: -f means "force installation". npm gives an ominous warning like "I hope you know what you're doing". Afaik fsevents isn't dangerous to have on a win32 machine. It only "works" on mac. The npm page for fsevents says "This is a low-level library. For a cross-platform file watching module that uses fsevents, check out Chokidar". I was only upgrading and wasn't choosing to use it on a win32 machine. So keep that in-mind.
That being-said, it didn't break anything for me. No BSoDs, errors, etc. App still works. Build works. All good.
This error message says that fsevents package does not support your operating system. In my case the solution for this error was to upgrade npm to the latest version.
please first delete package-lock.json file and remove "win-node-env": "^0.4.0" this line from package.json
This is what worked for me:
Delete node_modules
Delete package-lock.json
run npm i
Add peer dependency in your JSON package like below
{
"name": "chai-as-promised",
"peerDependencies": {
"chai": "1.x"
}
}

Npm error unsupported platform for fsEvents when deploying to Azure

When I run npm install, I get this error:
npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for
fsevents#1.1.3: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"}) npm ERR! notsup Valid OS: darwin npm
ERR! notsup Valid Arch: any npm ERR! notsup Actual OS: win32 npm
ERR! notsup Actual Arch: x64
This has been asked here but the accepted answer that it is optional does not work for me as I am unable to publish to azure since npm install fails.
npm version : 5.6.0
I have tried:
npm install --no-optional
npm i -f doesn't sound like a good idea...
Instead, add fsevents to optional dependencies (if fsevents is in your package.json):
"optionalDependencies": {
"fsevents": "^2.0.7"
}
#Aaron is correct. This was failing when I was running npm install from within maven-frontend-plugin.
I resolved the issue using the command npm i -f
( npm install forced)
fsevents is an OS X-only module, you can't install it on Windows.
fsevents is only needed if you are building on a Mac. If you are deploying to ubuntu, windows, etc it's not needed.
See here npm package.json OS specific dependency which reads,
npm package.json supports an os key,
and also optionalDependencies
os can be used to specify which OS a module can be installed on.
optionalDependencies are module dependencies that if they cannot be
installed, npm skips them and continues installing.
Either one will work. I prefer adding the following to my package.json's root object:
"optionalDependencies": {
"fsevents": "^2.1.2",
},
It is nothing to deal with Darwin or Windows . You might have installed the Angular but system variable path is not updated accordingly .
Get the ng install location from your system something like(C:\Users.....\AppData\Roaming\npm) and add at the end of system variable path .
now go to Cmd -> type ng-v for Angular 6 ( ng v or ng version for Angular 7 ).
I know this question is old, but for other people still facing this issue especially on mac0S, there seems to be some platform specificity issue around the whole thing. I encountered the problem while trying to deploy to Heroku, I did the following, the build became successful and the deployment worked afterward. So kindly do the following:
Add your preferred version of fsevents to optionalDependencies in your package.json
Run npm install afterward.
I assume you do not currently have an entry for optionalDependencies in your package.json, so here you go:
"optionalDependencies": {
"fsevents": "2.x.x"
}
This worked effortless for me on Windows:
Go to project's "package.lock.json" file
Press "Ctrl+F" (to enable keyword search)
Type "darwin"
Wherever it says "darwin" in the file, change that to "win32"
Restart your VS Code and you should be good to go.
add this it works for me
"main": "server.js",
"type": "module",
"engines": { "node": "16.10.0", "npm": "7.24.2" },

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents

I'm trying to run this project.
After updating minimatch version to 3.10.9, I'm getting the following error:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\webpack\node_modules\watchpack\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.0.14: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
My configuration:
Node v - 4.4.2
npm v - 3.10.9
32 bit windows OS
It's a warning, not an error. It occurs because fsevents is an optional dependency, used only when project is run on macOS environment (the package provides 'Native Access to Mac OS-X FSEvents').
And since you're running your project on Windows, fsevents is skipped as irrelevant.
There is a PR to fix this behaviour here: https://github.com/npm/cli/pull/169
This still appears to be an issue, causing package installations to be aborted with warnings about optional packages not being installed because of "Unsupported platform".
The problem relates to the "shrinkwrap" or package-lock.json which gets persisted after every package manager execution. Subsequent attempts keep failing as this file is referenced instead of package.json.
Adding these options to the npm install command should allow packages to install again.
--no-optional argument will prevent optional dependencies from being installed.
--no-shrinkwrap argument, which will ignore an available package lock or
shrinkwrap file and use the package.json instead.
--no-package-lock argument will prevent npm from creating a package-lock.json file.
The complete command looks like this:
npm install --no-optional --no-shrinkwrap --no-package-lock
nJoy!
Using parameter --force:
npm i -f
This answer worked for me, add this to your package.json
"optionalDependencies": {
"fsevents": "^2.3.2"
}
Unsupported platform for fsevents
The current best solution is upgrading your version of npm, which won't have this warning.
If using a Windows machine, an easy way to upgrade is with the tool Upgrade npm on Windows.

Requiring unknown module ./bindings on react native

I'm trying to run my react-native project on android but when I try to execute it I get the following error on the android simulator:
"Requiering unknown module ./bindings. If you are sure the module is
there, try restarting the packager or running npm install"
The thing is that I have checked up node_modules and I can see that the module is there. I have already tried to remove node_modules and install all of them again but didn't work.
I have also tried to install bindings with npm install bindings and I get the following error:
npm WARN optional Skipping failed optional dependency
/noble/bluetooth-hci-socket:
npm WARN notsup Not compatible with your operating system or
architecture: bluetooth-hci-socket#0.4.4
I'm on MACOS

Resources