npm install lite-server --save-dev error - node.js

I'm trying to use node for the first time in a VS project in windows. I installed node.js, below is the info:
node -v
v8.9.3
npm -v
5.5.1
Completed setup in the project using npm init, that seemed to work fine.
npm install lite-server --save-dev produced the following error:
$ npm install lite-server --save-dev
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
I don't understand the errors. Help. Thanks!

The error comes from fsevents#1.1.3, which is a dependency package of lite-server.
fsevents#1.1.3 only works in macOS. See its npm info page.
Native access to OS X FSEvents in Node.js
The FSEvents API in OS X allows applications to register for
notifications of changes to a given directory tree. It is a very fast
and lightweight alternative to kqueue.
Similar issues also apply to other npm packages with such dependency.
I am using npm#5.6.0, the latest stable release, and tried install on my Windows. The error turns out to a warning and let lite-server installed eventually. Anyway, fsevents is just an optional dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.1.3 (node_modules\lite-server\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"})
+ lite-server#2.3.0
added 279 packages in 81.466s

I found the fix for Ubuntu 18.04/20.04 after working for whole day. This should work for other Linux distros
Run following command for globally using lite-server
sudo npm install lite-server -g
Your package.json file should contain
"devDependencies": {
"lite-server": "^2.5.4"
}
and scipt should look like
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"lite": "lite-server"
},
For development mode run following
sudo npm i lite-server --save-dev
Local server could started using npm command
npm start

Related

Gatsby default starter

This error came when I created gatsby-default-starter site. How to solve it. What is the problem with it?
Error message:
‼ pngquant pre-build test failed i compiling from source × Error: pngquant failed to build, make sure that libpng-dev is installed at D:\gatsby-project\my-gatsby-project\node_modules\bin-build\node_modules\execa\index.js:231:11 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:93:5) at async Promise.all (index 0) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.2 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! pngquant-bin#6.0.0 postinstall: node lib/install.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the pngquant-bin#6.0.0 postinstall 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:
ERROR
Command failed with exit code 1: npm install
Error: Command failed with exit code 1: npm install
error.js:56 makeError [npm]/[gatsby-cli]/[execa]/lib/error.js:56:11
index.js:114 handlePromise [npm]/[gatsby-cli]/[execa]/index.js:114:26
task_queues.js:93 processTicksAndRejections internal/process/task_queues.js:93:5
init-starter.js:135 install [npm]/[gatsby-cli]/lib/init-starter.js:135:7
init-starter.js:202 clone [npm]/[gatsby-cli]/lib/init-starter.js:202:3
init-starter.js:343 initStarter [npm]/[gatsby-cli]/lib/init-starter.js:343:5
create-cli.js:494 [npm]/[gatsby-cli]/lib/create-cli.js:494:9
It seems that you are using Windows as OS. This issue is usually related to some additional dependencies that you may need. Try the following:
Delete your project (to avoid potentially corrupted dependencies).
Install the windows-build-tools by:
npm install --global windows-build-tools --vs2015
Run your starter command and develop it. For example:
npm install -g gatsby-cli
gatsby new gatsby-site
cd gatsby-site
gatsby develop
If the issue persists try installing manually the missing dependencies by:
npm install imagemin-pngquant#5.0.1 --save
npm install pngquant-bin#3.1.1 --save
For further details check Gatsby on Windows docs.

Unsupported engine node / NPM only when building in Docker

I have a dependency in my package.json which itself has the following dependency:
"node-rdkafka": "^2.5.0",
Using nvm on my local machine and setting my node version to 8.9.1, and my npm version is 5.5.1, I can successfully run
npm install node-rdkafka#2.7.1
But when running the same thing (i.e npm install) from within my docker image:
FROM node:10.13.0-alpine or FROM node:8.9.1-alpine
I get the following error:
npm ERR! notsup Unsupported engine for node-rdkafka#2.7.1: wanted: {"node":">=12.0.0"} (current: {"node":"10.13.0","npm":"6.4.1"})
npm ERR! notsup Not compatible with your version of node/npm: node-rdkafka#2.7.1
npm ERR! notsup Not compatible with your version of node/npm: node-rdkafka#2.7.1
npm ERR! notsup Required: {"node":">=12.0.0"}
npm ERR! notsup Actual: {"npm":"6.4.1","node":"10.13.0"}
Any ideas about this inconsistency?
I clearly dont need a node version this high. But it says I do.
Try to remove package-lock.json before npm install in Docker
rm package-lock.json
npm i
The engines property in the package.json allows us to establish a range of versions.
With >=12 is asking for a node with version 12 or greater.
Therefore, the solution would be to install the requested version:
FROM node:12
Anyway, I recommend reviewing the versions supported by Docker currently here.

NPM List errors for missing dependencies of uninstall optional dependencies

I have an npm project which needs to build on both Mac and Windows build servers. (This is for an Ionic mobile app, but I don't think that is relevant to my issue.) One of our dependencies has a dependency on fsevents, which is skipped by npm install on Windows machines. However, if I run npm list --depth=0, it is returning errors about missing dependencies of optional dependencies.
Minimal package.json to reproduce:
{
"dependencies": {
"#ionic/app-scripts": "^3.2.0"
}
}
Then I run npm install:
C:\temp\nodetest>npm install
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.7 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
Notice that it skips fsevents because it does not support Windows OS.
Now I run npm list:
C:\temp\nodetest>npm list --depth=0
C:\temp\nodetest
`-- #ionic/app-scripts#3.2.3
npm ERR! missing: mkdirp#0.5.1, required by node-pre-gyp#0.10.3
npm ERR! missing: minimist#0.0.8, required by mkdirp#0.5.1
npm ERR! missing: minimatch#3.0.4, required by ignore-walk#3.0.1
... (many other errors like this)
The errors are all due to dependencies of the uninstalled optional dependency. Is there any way to suppress these errors? I'm not seeing anything in the npm list documentation.
My ultimate goal is to verify that all dependencies are installed, and fail the build otherwise. I'm currently using npm list to do that. Is there a better way to do this? We don't want to run npm install or npm update on every build, because we got many surprise bugs in the past when we did that.
I've also tried npm list --depth=0 --no-optional (based on this question), but it doesn't look like --no-optional command is relevant to npm list.

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" },

how do I install npm packages in linux machine

I've installed nodejs v7.5.0 and npm v4.1.2 in my 32 bit linux mint machine. while I'm typin' npm install into terminal, it gives me these informations instead of being installed npm packages are:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"ia32"})
npm WARN #angular/core#2.4.7 requires a peer of rxjs#^5.0.1 but none was installed.
npm WARN shwokat#1.0.0 No description
npm WARN shwokat#1.0.0 No repository field
Now where's my wrong? how to solve it and install npm packages correctly, please let me know?
Try sudo npm install npm -g
Go through the official guide.

Resources