elixir - phoenix新项目创建依赖安装阶段出错

标签 elixir phoenix-framework

我正在尝试遵循 Phoenix 框架的 Up and Running 指南。我使用的是Windows 8.1,软件版本如下:

  • Elixir - 1.0.4
  • 节点 - v0.10.13
  • npm - 1.3.2

当我运行命令mix phoenix.new hello_phoenix时,在我说Y获取并安装依赖项? [Yn] y 在应用程序创建过程中,我注意到控制台中出现以下错误(也可在 npm-debug.log 中找到)

...
npm http GET https://registry.npmjs.org/bytes/-/bytes-0.2.0.tgz
npm http 200 https://registry.npmjs.org/uid2/-/uid2-0.0.2.tgz
npm http 200 https://registry.npmjs.org/formidable/-/formidable-1.0.14.tgz
npm http 200 https://registry.npmjs.org/bytes/-/bytes-0.2.0.tgz

[eval]:1
"require('fs').readdir('lib',function(e){e&&require('child_process').exec('npm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected token ILLEGAL
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:532:25)
    at startup (node.js:80:7)
    at node.js:901:3
npm ERR! weird error 8
npm ERR! Error: ENOENT, lstat 'C:\Users\srikps\AppData\Local\Temp\npm-12976\1437663559041-0.8095405038911849\package\src\libsass\subset_map.hpp'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a140a17573a1d15151d161f1d08150f0a0954191517" rel="noreferrer noopener nofollow">[email protected]</a>>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd E:\elixir\hello_phoenix
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! path C:\Users\srikps\AppData\Local\Temp\npm-12976\1437663559041-0.8095405038911849\package\src\libsass\subset_map.hpp
npm ERR! fstream_path C:\Users\srikps\AppData\Local\Temp\npm-12976\1437663559041-0.8095405038911849\package\src\libsass\subset_map.hpp
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm http GET https://registry.npmjs.org/os-homedir
npm http GET https://registry.npmjs.org/os-tmpdir
npm http GET https://registry.npmjs.org/xtend
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/is-finite
npm http GET https://registry.npmjs.org/leven
npm http GET https://registry.npmjs.org/get-stdin

如果我尝试使用命令 mix phoenix.server 运行应用程序,我会看到以下错误

E:\elixir\hello_phoenix>mix phoenix.server
[info] Running HelloPhoenix.Endpoint with Cowboy on port 4000 (http)

module.js:340
    throw err;
          ^
Error: Cannot find module 'e:\elixir\hello_phoenix\node_modules\brunch\bin\brunch'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

如果我访问 http://localhost:4000 ,页面看起来不像 it should look like ,而是如下所示:

Phoenix app

我还尝试运行Phoenix Issue Page中提到的命令

rm -rf node_modules
npm cache clean
npm install

但是,我遇到了另一个错误:

...
npm http 200 https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.1.tgz
npm http 200 https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz

> <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="741606011a171c34455a4c5a47" rel="noreferrer noopener nofollow">[email protected]</a> postinstall E:\elixir\hello_phoenix\node_modules\brunch
> node -e "require('fs').readdir('lib',function(e){e&&require('child_process').exec('npm run prepublish')})"


[eval]:1
"require('fs').readdir('lib',function(e){e&&require('child_process').exec('npm
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected token ILLEGAL
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:532:25)
    at startup (node.js:80:7)
    at node.js:901:3
unbuild <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ceefef9e2efe4ccbda2b4a2bf" rel="noreferrer noopener nofollow">[email protected]</a>
npm http 200 https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz
npm http 200 https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz
npm http 200 https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz
...

最佳答案

我相信 Phoenix 至少需要 Node.js 版本 0.12.0。

关于elixir - phoenix新项目创建依赖安装阶段出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31594634/

相关文章:

web-services - Elixir 有 HTTP 路由库吗?

elixir - 无法创建 Rumbl.Repo 的数据库 : killed

elixir - 我可以将插头放在哪里,然后从 Phoenix 应用程序中的不同 Controller 使用它们?

elixir - 该应用程序未在观察者中列出

erlang - 在使用 :global. whereis_name 之前等待 Node.connect

elixir - 如何将 Kernel.apply 用于宏功能

ruby-on-rails - Phoenix 的scrub_params 是不是像Rails 的强参数?

phoenix-framework - Elixir Phoenix 内联 css 用于发送电子邮件

postgresql - Elixir Ecto : How to write a migration with belongs_to and has_many?

erlang - 生产环境未找到 OTP 模块 :httpc when using exrm