1

I have played Phoenix for a month, and everything has been fine until today. Today morning, it went wrong.

When I generate a new Phoenix app(called 'islands_interface') following official tutorial and other tutorials; $ ​​mix​​ ​​phx.new islands_interface $ cd islands_interface && cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development

The terminal show a long error message starting;

Module build failed: Error: Package exports for '/Users/Jupeter/islands_interface/assets/node_modules/@babel/helper-compilation-targets' do not define a '.' subpath 
...

When I connect to http://localhost:4000/, it shows the default welcome page, but when opening my Chrome browser console, it also shows a long error messages starting;

GET http://localhost:4000/css/app.css net::ERR_ABORTED 404 (Not Found)
app.js:1 Uncaught Error: Module build failed: Error: Package exports for '/Users/Jupeter/islands_interface/assets/node_modules/@babel/helper-compilation-targets' do not define a '.' subpath
    at applyExports (:4000/internal/modules/cjs/loader.js:485)
    at resolveExports (:4000/internal/modules/cjs/loader.js:508)
    at Function.
...

The error seems something related to npm and webpack, but don't know how to fix it. I have tried several times to make a brand new Phoenix app, but all show the same error messages. That is, the Phoenix doesn't work anymore even after reinstalling it.

$ mix archive.uninstall phx_new
$ mix archive.install hex phx_new 1.4.0

Thank you.

Adam Millerchip
  • 20,844
  • 5
  • 51
  • 74
주피터
  • 135
  • 6
  • Normally, phoenix executes the `webpack.js` command for you depending on your environment. Can you try to delete the `assets/node_modules` folder and simply run `npm install --prefix assets` again? – Peter Jan 12 '20 at 09:43
  • Thank you, Peter. I have tried, but, the problem is unchanged... – 주피터 Jan 12 '20 at 11:50

1 Answers1

2

I have removed all node related ones from my computer. See How to uninstall npm modules in node js?

Then, I have reinstalled it. The problem has disappeared.

People in Elixir forum has helped me a lot. https://elixirforum.com/t/phoenix-not-working/28182/17

Thank you all...

주피터
  • 135
  • 6