添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Getting started guide raises an error: npm install, node-gyp python2 couldn't be found #4359

@czardien

Description

Environment

  • Elixir version (elixir -v):
  • Erlang/OTP 24 [erts-12.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
    Elixir 1.12.1 (compiled with Erlang/OTP 24)
    
  • Phoenix version (mix deps):
  • * phoenix 1.5.9 (Hex package) (mix)
      locked at 1.5.9 (phoenix) 7e4bce20
    * phoenix_ecto 4.3.0 (Hex package) (mix)
      locked at 4.3.0 (phoenix_ecto) 0ac49192
    * phoenix_html 2.14.3 (Hex package) (mix)
      locked at 2.14.3 (phoenix_html) efd697a7
    * phoenix_live_dashboard 0.4.0 (Hex package) (mix)
      locked at 0.4.0 (phoenix_live_dashboard) 8d52149e
    * phoenix_live_reload 1.3.2 (Hex package) (mix)
      locked at 1.3.2 (phoenix_live_reload) 6d6f1d35
    * phoenix_live_view 0.15.7 (Hex package) (mix)
      locked at 0.15.7 (phoenix_live_view) 3a756cf6
    * phoenix_pubsub 2.0.0 (Hex package) (mix)
      locked at 2.0.0 (phoenix_pubsub) c52d948c
    
  • Node.js version (node -v):
  • v16.4.1
    
  • NPM version (npm -v):
  • 7.17.0
    
  • Operating system:
  • Arch Linux, uname -a:

    Linux shash-mind 5.12.14-arch1-1 #1 SMP PREEMPT Thu, 01 Jul 2021 07:26:06 +0000 x86_64 GNU/Linux
    

    Expected behavior

    The getting started guide doesn't fail in early steps.

    Actual behavior

    Just started following the up and running guide on the phoenix documentation for version 1.5.9 at: https://hexdocs.pm/phoenix/up_and_running.html#content.

    Running the first step is fine:

    mix phx.new antenna
    

    ... which logs, including instructions:

    * creating antenna/config/config.exs
    * creating antenna/config/dev.exs
    * creating antenna/config/prod.exs
    * creating antenna/config/prod.secret.exs
    * creating antenna/config/test.exs
    * creating antenna/lib/antenna/application.ex
    * creating antenna/lib/antenna.ex
    * creating antenna/lib/antenna_web/channels/user_socket.ex
    * creating antenna/lib/antenna_web/views/error_helpers.ex
    * creating antenna/lib/antenna_web/views/error_view.ex
    * creating antenna/lib/antenna_web/endpoint.ex
    * creating antenna/lib/antenna_web/router.ex
    * creating antenna/lib/antenna_web/telemetry.ex
    * creating antenna/lib/antenna_web.ex
    * creating antenna/mix.exs
    * creating antenna/README.md
    * creating antenna/.formatter.exs
    * creating antenna/.gitignore
    * creating antenna/test/support/channel_case.ex
    * creating antenna/test/support/conn_case.ex
    * creating antenna/test/test_helper.exs
    * creating antenna/test/antenna_web/views/error_view_test.exs
    * creating antenna/lib/antenna/repo.ex
    * creating antenna/priv/repo/migrations/.formatter.exs
    * creating antenna/priv/repo/seeds.exs
    * creating antenna/test/support/data_case.ex
    * creating antenna/lib/antenna_web/controllers/page_controller.ex
    * creating antenna/lib/antenna_web/templates/layout/app.html.eex
    * creating antenna/lib/antenna_web/templates/page/index.html.eex
    * creating antenna/lib/antenna_web/views/layout_view.ex
    * creating antenna/lib/antenna_web/views/page_view.ex
    * creating antenna/test/antenna_web/controllers/page_controller_test.exs
    * creating antenna/test/antenna_web/views/layout_view_test.exs
    * creating antenna/test/antenna_web/views/page_view_test.exs
    * creating antenna/lib/antenna_web/gettext.ex
    * creating antenna/priv/gettext/en/LC_MESSAGES/errors.po
    * creating antenna/priv/gettext/errors.pot
    * creating antenna/assets/webpack.config.js
    * creating antenna/assets/.babelrc
    * creating antenna/assets/js/app.js
    * creating antenna/assets/css/app.scss
    * creating antenna/assets/js/socket.js
    * creating antenna/assets/package.json
    * creating antenna/assets/static/favicon.ico
    * creating antenna/assets/css/phoenix.css
    * creating antenna/assets/static/images/phoenix.png
    * creating antenna/assets/static/robots.txt
    Fetch and install dependencies? [Yn] Y
    * running mix deps.get
    * running cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development
    * running mix deps.compile
    We are almost there! The following steps are missing:
        $ cd antenna
        $ cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development
    Then configure your database in config/dev.exs and run:
        $ mix ecto.create
    Start your Phoenix app with:
        $ mix phx.server
    You can also run your app inside IEx (Interactive Elixir) as:
        $ iex -S mix phx.server
    

    From there, I go into the next step:

    $ cd antenna
    $ cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development
    

    ... which raises:

    npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
    npm WARN deprecated har-validator@5.1.5: this library is no longer supported
    npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
    npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
    npm WARN deprecated querystring@0.2.0: The
    npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
    npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
    npm ERR! code 1
    npm ERR! path /home/adrien/code/czard/antenna/assets/node_modules/node-sass
    npm ERR! command failed
    npm ERR! command sh -c node scripts/build.js
    npm ERR! Building: /usr/bin/node /home/adrien/code/czard/antenna/assets/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
    npm ERR! gyp info it worked if it ends with ok
    npm ERR! gyp verb cli [
    npm ERR! gyp verb cli   '/usr/bin/node',
    npm ERR! gyp verb cli   '/home/adrien/code/czard/antenna/assets/node_modules/node-gyp/bin/node-gyp.js',
    npm ERR! gyp verb cli   'rebuild',
    npm ERR! gyp verb cli   '--verbose',
    npm ERR! gyp verb cli   '--libsass_ext=',
    npm ERR! gyp verb cli   '--libsass_cflags=',
    npm ERR! gyp verb cli   '--libsass_ldflags=',
    npm ERR! gyp verb cli   '--libsass_library='
    npm ERR! gyp verb cli ]
    npm ERR! gyp info using node-gyp@3.8.0
    npm ERR! gyp info using node@16.4.1 | linux | x64
    npm ERR! gyp verb command rebuild []
    npm ERR! gyp verb command clean []
    npm ERR! gyp verb clean removing "build" directory
    npm ERR! gyp verb command configure []
    npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
    npm ERR! gyp verb `which` failed Error: not found: python2
    npm ERR! gyp verb `which` failed     at getNotFoundError (/home/adrien/code/czard/antenna/assets/node_modules/which/which.js:13:12)
    npm ERR! gyp verb `which` failed     at F (/home/adrien/code/czard/antenna/assets/node_modules/which/which.js:68:19)
    npm ERR! gyp verb `which` failed     at E (/home/adrien/code/czard/antenna/assets/node_modules/which/which.js:80:29)
    npm ERR! gyp verb `which` failed     at /home/adrien/code/czard/antenna/assets/node_modules/which/which.js:89:16
    npm ERR! gyp verb `which` failed     at /home/adrien/code/czard/antenna/assets/node_modules/isexe/index.js:42:5
    npm ERR! gyp verb `which` failed     at /home/adrien/code/czard/antenna/assets/node_modules/isexe/mode.js:8:5
    npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:195:21)
    npm ERR! gyp verb `which` failed  python2 Error: not found: python2
    npm ERR! gyp verb `which` failed     at getNotFoundError (/home/adrien/code/czard/antenna/assets/node_modules/which/which.js:13:12)
    npm ERR! gyp verb `which` failed     at F (/home/adrien/code/czard/antenna/assets/node_modules/which/which.js:68:19)
    npm ERR! gyp verb `which` failed     at E (/home/adrien/code/czard/antenna/assets/node_modules/which/which.js:80:29)
    npm ERR! gyp verb `which` failed     at /home/adrien/code/czard/antenna/assets/node_modules/which/which.js:89:16
    npm ERR! gyp verb `which` failed     at /home/adrien/code/czard/antenna/assets/node_modules/isexe/index.js:42:5
    npm ERR! gyp verb `which` failed     at /home/adrien/code/czard/antenna/assets/node_modules/isexe/mode.js:8:5
    npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:195:21) {
    npm ERR! gyp verb `which` failed   code: 'ENOENT'
    npm ERR! gyp verb `which` failed }
    npm ERR! gyp verb check python checking for Python executable "python" in the PATH
    npm ERR! gyp verb `which` succeeded python /usr/bin/python
    npm ERR! gyp ERR! configure error
    npm ERR! gyp ERR! stack Error: Command failed: /usr/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
    npm ERR! gyp ERR! stack   File "<string>", line 1
    npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
    npm ERR! gyp ERR! stack                       ^
    npm ERR! gyp ERR! stack SyntaxError: invalid syntax
    npm ERR! gyp ERR! stack
    npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:397:12)
    npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
    npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
    npm ERR! gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:453:11)
    npm ERR! gyp ERR! stack     at Socket.emit (node:events:394:28)
    npm ERR! gyp ERR! stack     at Pipe.<anonymous> (node:net:662:12)
    npm ERR! gyp ERR! System Linux 5.12.14-arch1-1
    npm ERR! gyp ERR! command "/usr/bin/node" "/home/adrien/code/czard/antenna/assets/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    npm ERR! gyp ERR! cwd /home/adrien/code/czard/antenna/assets/node_modules/node-sass
    npm ERR! gyp ERR! node -v v16.4.1
    npm ERR! gyp ERR! node-gyp -v v3.8.0
    npm ERR! gyp ERR! not ok
    npm ERR! Build failed with error code: 1
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/adrien/.npm/_logs/2021-07-02T16_11_00_305Z-debug.log
    

    I am not familiar with npm but I thought this part would be straightforward, any idea what is going here?