【问题标题】:npm config set command not working properlynpm config set 命令无法正常工作
【发布时间】:2019-01-01 01:08:57
【问题描述】:

我使用命令为 package.json 文件设置默认配置,

npm config set init-main "script.js"

在此之后,我使用

初始化了一个文件夹
npm init --yes

但主要还是“index.js”。但是,如果我写

npm config get init-main

它返回“script.js”。我在文档中找不到任何相关内容。请帮忙。提前致谢。

【问题讨论】:

    标签: npm npm-config


    【解决方案1】:

    不幸的是,npm config set 允许您设置任何东西,例如。你可以这样做:

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

    您可能只想在package.json 中将字段main 编辑为"index.js" 似乎不存在npm 的任何此类配置(没有init-main 描述https://docs.npmjs.com/misc/config )。也许是旧的/不稳定的版本有它?

    (在这种情况下,npm config 可能会显示警告或某些信息,例如“警告,无法识别的配置 'init-main'”,但它不会...)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多