Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Cannot find module '/Users/wyb/.nvm/versions/io.js/v3.0.0/lib/node_modules/pm2/lib/ProcessContainerFork.js'

Tags:

node.js

pm2

After removing the older version of nvm, i installed the latest version of node by using homebrew. However, i got some problem starting my project using pm2:

pm2-dev server.js

It loaded the path including nvm. Here is the log:

Error: Cannot find module '/Users/wyb/.nvm/versions/io.js/v3.0.0/lib/node_modules/pm2/lib/ProcessContainerFork.js'

like image 253
wyb Avatar asked Apr 18 '16 09:04

wyb


People also ask

Why is my module not showing up in NPM?

The cannot find module error occurs because NPM cannot find the module required by the index.js file. In this case, the axios module. To resolve the error, you need to make sure that axios is installed in the node_modules/ folder.

What does “cannot find module” mean?

To conclude, the error “Cannot find module” happens when Node.js can’t find the module that a file is trying to import. You can see the file and the module that’s causing the issue from the error output generated by Node itself.

Why can't I find the module'C'in Node JS?

If you are trying to run your Node.js application and you get something like this: Error: Cannot find module 'C:UsersMemy_app.js'. then you are most likely trying to run the wrong file.

How do I fix the error when importing a node module?

For TypeScript users, if you are importing a built-in Node module (such as http, pathor url) and you are getting an error such as "Cannot find module "x"then the error can be fixed by running npm install @types/node --save-dev


1 Answers

The reason is you pm2 env is modified, please try run command below to delete your pm2 env dir from your home dir.

rm -rf ~/.pm2

Now rerun your pm2-dev server.js, pm2 will refresh env.

like image 193
gongzili456 Avatar answered Sep 19 '22 13:09

gongzili456