1

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!

themefield
  • 3,847
  • 30
  • 32

2 Answers2

2

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
themefield
  • 3,847
  • 30
  • 32
  • For the other readers : the parameter to skip optional dependencies is "no-optional" -> npm install --save-dev --no-optional lite-server – Florimond Dec 03 '19 at 18:15
1

I found the fix for Ubuntu 18.04/20.04 after working for whole day. This should work for other Linux distros

  1. Run following command for globally using lite-server

     sudo npm install lite-server -g
    
  2. 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"
  },
  1. For development mode run following

     sudo npm i lite-server --save-dev
    
  2. Local server could started using npm command

     npm start