Having problems with mix phx.new

I’m having problems getting Phoenix to install. After upgrading to Elixir 1.6.1, I ran:

$ ez=https://github.com/phoenixframework/archives/raw/master/phx_new.ez
$ mix archive.install $ez
$ mix phx.new mudlark --no-ecto
...
Fetch and install dependencies? [Yn] y
* running mix deps.get
* running mix deps.compile
* running cd assets && npm install && node node_modules/brunch/bin/brunch build  <- Take 1

We are almost there! The following steps are missing:

    $ cd mudlark
    $ cd assets && npm install && node node_modules/brunch/bin/brunch build      <- Take 2?

It seemed odd that mix was asking me to do an install and build that it had just done,
but I decided that it couldn’t hurt, so:

$ cd mudlark
$ cd assets && npm install && node node_modules/brunch/bin/brunch build
npm WARN package.json @ No description
npm WARN package.json @ No README data
npm ERR! notarget No compatible version found: phoenix_html@'file:../deps/phoenix_html'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["2.10.4"]
npm ERR! notarget 
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! System Darwin 14.5.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Volumes/Fido/Local/u/rdm/Private/Work/P_OSM/AxMaps/elixir/mudlark/assets
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ETARGET
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     ~/Work/P_OSM/AxMaps/elixir/mudlark/assets/npm-debug.log
npm ERR! not ok code 0

I’v never used npm before, but it seems to be saying that it can’t find version 2.10.4 of a file. I’m not sure what to do at this point…

1 Like

Did you installed the node with homebrew?

if yes take a look at this gist[1]

[1] https://gist.github.com/DanHerbert/9520689

1 Like

I tried the instructions on that site, but they simply led me deeper into the morass.

For one thing, it seems that they are incomplete, so I had to “sudo rm -rf /usr/local/lib/node” as well as “sudo rm -rf /usr/local/lib/node_modules”.
Then, when I tried the curl command, it came apart into tiny pieces:

$ curl -L https://www.npmjs.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6255 100 6255 0 0 9415 0 --:–:-- --:–:-- --:–:-- 26281
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-5.6.0.tgz

module.js:340
throw err;
^
Error: Cannot find module…

Apparently, the problem had to do with incompatibilities between brew and npm, rather than anything specific to npm, per se. In any case, I ended up removing the Homebrew node and npm files, then installing using the official macOS PKG for npm:

$ sudo rm -rf /usr/local/lib/node
$ sudo rm -rf /usr/local/lib/node_modules
$ brew uninstall node
$ rm -rf ~/.npm-packages

Get and run the PKG from https://nodejs.org/en/download.
Do some sanity checks:

$ node -v 
v8.9.4
$ npm -v  
5.6.0
$ npm list -g --depth=0  
/Users/rdm/.npm-packages/lib
└── (empty)

Try the mix command again:

$ mix phx.new mudlark --no-ecto
...
Fetch and install dependencies? [Yn] y
* running mix deps.get
* running mix deps.compile
* running cd assets && npm install && node 
  node_modules/brunch/bin/brunch build

We are all set! Go into your application by running: ...

-r

3 Likes