npm config set command not working properly

5.8k Views Asked by At

i set the default config for the package.json file using the command,

npm config set init-main "script.js"

after this i initialized a folder using

npm init --yes

but the main is still "index.js". But, if i write

npm config get init-main

it returns "script.js". I could not find anything related in the documentation. Please help. Thanks in advance.

2

There are 2 best solutions below

0
On

Unfortunately, npm config set allows you to set anything, eg. you can do something like:

npm config set foo "bar"
npm config get foo  # outputs: bar

You probably just want to edit in package.json the field main to "index.js", there does not appear to exist any such config for npm (no init-main described https://docs.npmjs.com/misc/config). Maybe an older/unstable verion had it?

(npm config should probably show a warning or somerhing in this case, like "warning, unrecognized config 'init-main'", but it doesn't...)

0
On

The following command. npm pkg set main=script.js