nodejs module.js:340 error: cannot find module

前端 未结 21 582
别那么骄傲
别那么骄傲 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:17

    EDIT: This answer is outdated. With things like Yarn and NPM 5's lockfiles it is now easier to ensure you're dependencies are correct on platforms like Heroku

    I had a similar issue related to node_modules being modified somehow locally but the change was not reflect on Heroku, causing my app to crash. It's relatively easy fix if this is your issue:

    # Remove node_modules
    rm -fr node_modules
    
    # Reinstall packages
    npm i
    
    # Commit changes
    git add node_modules
    git commit -m 'Fix node_modules dependencies.'
    git push heroku master
    

    Hope that helps for others with a similar issue.

提交回复
热议问题