【问题标题】:npm init not creating package.json on my macnpm init 不在我的 Mac 上创建 package.json
【发布时间】:2014-03-25 19:43:31
【问题描述】:

当我尝试使用npm init 创建package.json 文件时,我不断收到以下信息:

npm http GET https://registry.npmjs.org/init
npm http 304 https://registry.npmjs.org/init
npm http GET https://registry.npmjs.org/daemon
npm http 304 https://registry.npmjs.org/daemon
init@0.1.2 node_modules/init
└── daemon@1.1.0

怎么了?我到处寻找,我找不到答案。 这是我运行以下命令时得到的结果:

Amens-Mac-mini:~ amenmojara$ npm init =ddd
npm http GET https://registry.npmjs.org/%3Dddd
npm http GET https://registry.npmjs.org/init
npm http 304 https://registry.npmjs.org/init
npm http 404 https://registry.npmjs.org/%3Dddd
npm ERR! 404 '%3Dddd' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.

npm ERR! System Darwin 13.0.0
npm ERR! command "/usr/local/Cellar/node/0.10.26/bin/node" "/usr/local/bin/npm" "install" "init"   "=ddd"
npm ERR! cwd /Users/amenmojara
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! code E404
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/amenmojara/npm-debug.log
npm ERR! not ok code 0

【问题讨论】:

    标签: json node.js npm


    【解决方案1】:

    试试这个。

    1. 转到终端。

    2. 更改要创建文件的目录位置。

      cd your_destination_folder

    3. 输入npm init 并按回车键。

    4. 它要求name, version, description, entry point, test command, git repository, keywords, author, license。传递这些值。

    5. 然后提示,Is this ok? (yes)。输入yes

    万岁,您的package.json 文件已创建。

    【讨论】:

    • 我已经尝试过了,当我发布这个问题时,我得到了你看到的结果。
    • 我猜,你可以试试sudo npm init。它会要求输入管理员密码。我不确定它是否有帮助,但至少尝试一下。
    • 是的,我必须添加 sudo nom init ,谢谢
    【解决方案2】:

    您正在使用npm install init 而不是npm init。只需检查您的 npm <something> 是否没有别名为 npm install <something>

    【讨论】:

    • 如果您使用 bash shell,别名大多在 bash 配置文件之一中定义 - /etc/profile ~/.bash_profile 或 ~/.bash_login 或 ~/.profile ~/.bash_logout ~/.bashrc
    • 试试这个。通过 which npm 检查 npm 的位置。复制该位置并运行它以提供完整路径。在我的 Mac 上 - /usr/local/bin/npm init
    • 在我的 Mac 上是 /usr/local/bin/npm 我刚刚运行了 nom init -ddd 并编辑了我的问题,该输出告诉你什么了吗?
    • 是的...尝试运行npm install init =ddd,您应该会看到相同的输出
    猜你喜欢
    • 2016-10-19
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 2020-05-16
    • 1970-01-01
    • 2019-05-31
    • 2019-07-13
    • 1970-01-01
    相关资源
    最近更新 更多