Why I Get "Uncaught Error: Cannot Find Module 'Multi. Js' " When Module Is Installed Globally?

I have installed the packacge multi.js as npm install --global --verbose multi.js and also set the NODE_PATH environment variable to the export NODE_PATH=/home/wasim/.nvm/versions/node/v13.1.0/lib/node_module. I can also view that module is indeed installed globally as,

npm list -g -depth 0
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

However, when I load the module as const multi_js = require('multi.js');, I get error: Cannot find module 'multi.js' as shown in the screenshot below

What I'm missing here? Thanks

Note: this error also occurs for local installation of multi.js package.

2

2 Answers

Try this workaround probably is the best way to import multi nowadays via npm/yarn

I am coding in 'non es6' js standard, so I tried const multi = require('../libs/multi.js-master/dist/multi.min.js'); but it did not work, I got this error: index.js:85 Uncaught (in promise) TypeError: multi is not a function

What worked for me is loading multi.min.js in the index.html as follows:

<script src="../libs/multi.js-master/dist/multi.min.js"></script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest