【问题标题】:Installing Cycle.js and running examples: enoent package.json file is missing安装 Cycle.js 并运行示例:enoent package.json 文件丢失
【发布时间】:2016-01-22 14:29:07
【问题描述】:

我在 NodeJs 方面没有太多经验。我想试试 Cyclejs。 documentation 说:

创建一个新目录并在该目录中运行:

npm install rx @cycle/core @cycle/dom

当我这样做时,我收到以下警告:

➜  cycle-examples  npm install rx @cycle/core @cycle/dom
/Users/mertnuhoglu/projects/js/tmp2/cycle-examples
├── @cycle/core@5.0.1
├─┬ @cycle/dom@7.1.1
│ ├─┬ es6-map@0.1.1
│ │ ├── d@0.1.1
│ │ ├─┬ es5-ext@0.10.8
│ │ │ ├── es6-iterator@2.0.0
│ │ │ └── es6-symbol@3.0.1
│ │ ├─┬ es6-iterator@0.1.3
│ │ │ └── es6-symbol@2.0.1
│ │ ├─┬ es6-set@0.1.2
│ │ │ ├── es6-iterator@2.0.0
│ │ │ └── es6-symbol@3.0.1
│ │ ├── es6-symbol@0.1.1
│ │ └── event-emitter@0.3.4
│ ├── matches-selector@1.0.0
│ ├── vdom-parser@1.2.1
│ ├─┬ vdom-to-html@2.1.1
│ │ ├── escape-html@1.0.3
│ │ ├─┬ param-case@1.1.1
│ │ │ └─┬ sentence-case@1.1.2
│ │ │   └── lower-case@1.1.2
│ │ └── xtend@4.0.0
│ ├─┬ virtual-dom@2.1.1
│ │ ├── browser-split@0.0.1
│ │ ├─┬ error@4.4.0
│ │ │ ├── camelize@1.0.0
│ │ │ └── string-template@0.2.1
│ │ ├─┬ ev-store@7.0.0
│ │ │ └── individual@3.0.0
│ │ ├─┬ global@4.3.0
│ │ │ ├─┬ min-document@2.17.0
│ │ │ │ └── dom-walk@0.1.1
│ │ │ └── process@0.5.2
│ │ ├── is-object@1.0.1
│ │ ├── next-tick@0.2.2
│ │ └── x-is-string@0.1.0
│ └── x-is-array@0.1.0
└── rx@4.0.6

npm WARN ENOENT ENOENT, open '/Users/mertnuhoglu/projects/js/tmp2/cycle-examples/package.json'
npm WARN EPACKAGEJSON cycle-examples No description
npm WARN EPACKAGEJSON cycle-examples No repository field.
npm WARN EPACKAGEJSON cycle-examples No README data
npm WARN EPACKAGEJSON cycle-examples No license field.

之后我克隆了循环示例并在instructions 之后运行npm start。我收到以下错误:

➜  cycle-examples  git clone https://github.com/cyclejs/cycle-examples
Cloning into 'cycle-examples'...
remote: Counting objects: 184, done.
remote: Total 184 (delta 0), reused 0 (delta 0), pack-reused 184
Receiving objects: 100% (184/184), 31.08 KiB | 0 bytes/s, done.
Resolving deltas: 100% (72/72), done.
Checking connectivity... done.
➜  cycle-examples  npm start
npm ERR! Darwin 14.0.0
npm ERR! argv "node" "/usr/local/bin/npm" "start"
npm ERR! node v0.12.7
npm ERR! npm  v3.3.8
npm ERR! path /Users/mertnuhoglu/projects/js/tmp2/cycle-examples/package.json
npm ERR! code ENOENT
npm ERR! errno -2

npm ERR! enoent ENOENT, open '/Users/mertnuhoglu/projects/js/tmp2/cycle-examples/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mertnuhoglu/projects/js/tmp2/cycle-examples/npm-debug.log

错误说我需要package.json。 git 存储库没有它。我应该自己创建吗?如果是这样,我应该在该文件中放入什么?

npm 版本是 3.3.8

我在 Node 中全局安装了 browserify@11.2.0 和 babel@5.8.23 库。

【问题讨论】:

  • 您可以尝试在运行npm start 之前键入cd cycle-examples 将目录更改为cycle-examples 吗? git clone 在现有目录中创建一个名为 cycle-examples 的新目录,该目录也称为 cycle-examples
  • 我只是查看了 cycle-examples 的 github 存储库,发现您还应该在运行 npm start 之前导航到示例文件夹。每个示例文件夹中都有一个package.json。所以你应该先运行cd cycle-examples/hello-world,然后运行npm start
  • 感谢 Nilgün,这实际上解决了问题。
  • 一般来说,npm init 会为你交互初始化一个package.json。这个想法是您跟踪该文件中的外部依赖项(您使用的库),指定版本、名称等,以便其他人可以轻松地在他们的机器上设置您的代码。查看本教程:youtube.com/watch?v=pU9Q6oiQNd0

标签: node.js cyclejs


【解决方案1】:

cycle-examples 是示例的集合。您需要输入一个实际的示例目录,例如 bmi-nested,然后从那里发出 npm start

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-26
    • 2017-07-30
    • 2014-09-16
    • 1970-01-01
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多