nodejs module.js:340 error: cannot find module

前端 未结 21 573
别那么骄傲
别那么骄傲 2021-02-02 06:39

I installed nodejs in C:\\Program Files (x86)\\nodejs

then I created a .js file and saved it in my desktop just to output \'hello world\' in the console:



        
相关标签:
21条回答
  • 2021-02-02 07:06

    Try npm install --production and then npm start.

    0 讨论(0)
  • 2021-02-02 07:06

    While i tried to run my first node application i had encountered the same issue but when i tried to see what the issue might be it was the path of the file. I was running the node .js from different location and hence encountered the issue. When i fixed the path this worked fine.

    0 讨论(0)
  • 2021-02-02 07:06

    If you are using a framework like express, you need to put the package.json file into the folder you are using and don't forget change main name.

    0 讨论(0)
  • 2021-02-02 07:06

    Make sure you saved the file as JavaScript. Un check 'Hide extensions for all known type' check box in Folder Options window will show you the correct file extension(Folder>>view>>Option).

    0 讨论(0)
  • 2021-02-02 07:08

    Try typing this into the Node command-line environment:

    .load c:/users/laura/desktop/nodeTest.js.

    It should work for what you're trying to do.

    If you want to call the file directly, you'd have to have it in the root directory where your Node installation resides.

    0 讨论(0)
  • 2021-02-02 07:09

    Easy way for this problem

    npm link e
    
    0 讨论(0)
提交回复
热议问题