Node.js Error: Cannot find module express

前端 未结 15 1387
情话喂你
情话喂你 2020-12-22 18:56

I wrote my first node.js app, but it can\'t find express library:

C:\\ChatServer\\Server>node server.js

module.js:340
    throw err;
          ^
Error: C         


        
相关标签:
15条回答
  • 2020-12-22 19:24

    On Ubuntu-based OS you can try

    sudo apt-get install node-express
    

    its working for me on Mint

    0 讨论(0)
  • 2020-12-22 19:25

    installing express globally will not work on your local project so you need to install it locally for use .

    npm install express
    

    Hope this will work

    Thank you

    0 讨论(0)
  • 2020-12-22 19:28

    I had this error in vscode, although the modules where installed. I am using typescript and express. In the server.ts files all the imports had red squiggly underlines. It turns out I had a faulty tsconfig.json file.

    {
        "compileOnSave": false,
        "compilerOptions": {
            "module": "commonjs", // Previously this value was `es6`
            "target": "es6",
            "allowSyntheticDefaultImports": true,
            "baseUrl": "public",
            "sourceMap": true,
            "outDir": "dist",
            "jsx": "react",
            "strict": true,
            "preserveConstEnums": true,
            "removeComments": true,
            "noImplicitAny": true,
            "allowJs": true
        },
        "exclude": [
            "node_modules",
            "build"
        ]
    }
    
    0 讨论(0)
提交回复
热议问题