简体   繁体   中英

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
├── http-server@0.12.3
├── multi.js@0.5.1
├── npm@6.14.8
├── xls@0.5.1
└── xlsx@0.16.6

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.

试试这个解决方法https://github.com/fabianlindfors/multi.js/issues/41可能是现在通过 npm/yarn 导入 multi 的最佳方式

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM