node.js, Error: Cannot find module 'express'

后端 未结 18 1897
情话喂你
情话喂你 2020-12-02 08:57

I am new to Node.js, try to learn express to build my first web application. I got stuck on my very first sample code and need some help to get it running. Before I post th

18条回答
  •  借酒劲吻你
    2020-12-02 09:46

    npm ERR! Error: ENOENT, open '/Users/feelexit/package.json'

    This happens due to missing permissions or unlinked files while npm was working.

    Meaning, that executing npm as this user doesn't have enough rights to read/write from a file, in this case package.json.

    try adding sudo before the entire command - it should resolve.

    $ sudo npm install -g express
    $ Password:*******

    Password would be your admin password of your mac.

    -g flag will install this module (express) in the global context of node - meaning node will/should recognize express module from within any js file without having to provide a full path to the module in use.

    Hope this helps!!

提交回复
热议问题