I have installed this module globally however it fails with an error when run due to a dependency error however if I run my local copy by running the command
node ./bin/xl-json
the command works. I believe when running the npm i -g xl-json command that dependencies aren't being installed properly. Any ideas why one way works and the other doesn't?
The reason it doesn't work is because it is not [exactly] the same command you are running.
If you look at the error you see:
if (cptable === 'undefined') cptable = require('./dist/cpexcel');
^
ReferenceError: cptable is not defined
When you run the global command xl-json
, the .cmd file (created by npm) takes precedence. iow. npm creates a file called xl-json.cmd which is a wrapper that invokes xl-json in the bin folder.
This file uses the strict option which the code should use but does not.
Try your command with --use-strict
and you should see the same error message. ie:
node --use-strict ./bin/xl-json
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.