1

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?

4

1 回答 1

1

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. i.e.:

node --use-strict ./bin/xl-json
于 2015-12-01T22:53:07.277 回答