I created a phoenix app while the nod version was 4_x. When I install 5_x instead I get errors on iex -S mix phoenix.server.
How do you solve this (except going back to node 4_x)?
[info] Running BpmServer.Endpoint with Cowboy using http on port 4000
Interactive Elixir (1.3.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> /stefan/bpm_demo/apps/bpm_server/node_modules/anymatch/index.js:29
result = criterion.test(string) || altString && criterion.test(altString);
^
TypeError: Cannot assign to read only property ‘lastIndex’ of object ‘[object RegExp]’
at RegExp.exec (native)
at RegExp.test (native)
at testCriteria (/stefan/bpm_demo/apps/bpm_server/node_modules/anymatch/index.js:29:26)
at Array.some (native)
at anymatch (/stefan/bpm_demo/apps/bpm_server/node_modules/anymatch/index.js:59:48)
at FileList.isIgnored (/stefan/bpm_demo/apps/bpm_server/node_modules/brunch/lib/fs_utils/file_list.js:66:16)
at FileList._change (/stefan/bpm_demo/apps/bpm_server/node_modules/brunch/lib/fs_utils/file_list.js:185:26)
at emitMany (events.js:127:13)
at FileList.emit (events.js:201:7)
at BrunchWatcher.changeFileList (/stefan/bpm_demo/apps/bpm_server/node_modules/brunch/lib/watch.js:227:19)
at BrunchWatcher.startCompilation (/stefan/bpm_demo/apps/bpm_server/node_modules/brunch/lib/watch.js:292:12)
at FSWatcher.chokidar.watch.on.on.absPath (/stefan/bpm_demo/apps/bpm_server/node_modules/brunch/lib/watch.js:166:14)
at emitTwo (events.js:106:13)
at FSWatcher.emit (events.js:191:7)
at FSWatcher. (/stefan/bpm_demo/apps/bpm_server/node_modules/chokidar/index.js:171:15)
at FSWatcher._emit (/stefan/bpm_demo/apps/bpm_server/node_modules/chokidar/index.js:212:5)
at FSWatcher.NodeFsHandler._handleFile (/stefan/bpm_demo/apps/bpm_server/node_modules/chokidar/lib/nodefs-handler.js:275:10)
at FSWatcher. (/stefan/bpm_demo/apps/bpm_server/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:123:15)
Did you clear your node_modules directory and any cache directories that you may have?
1 Like
I have no idea of cache dirs, I built the app along the lines layed out in the phoenix tutorial (I’m still a starter). If I clear the node_modules dir, is it repopulated then when I start phoenix.server with the new node_x?
When you run node install
it will redownload yep.
EDIT: Or was it npm install
… I think this one.
1 Like
npm install
indeed.
Not really helpfull at this moment but in the future I woud recommend to use nvm, it allows easy switching between node.js versions.
1 Like
What I did is make a backup of my project, create a new project with mix phoenix.new to see if it works with the new node version and eventually to make use of differences with the old project.
Within the old project
- I removed the contents of the node_modules
- executed npm install
Results were errors like "No license field’ + the deps folder was removed. So I
- copied the package.json that was generated with the new project and copied it to the old one
- copied deps from the backup.
- executed npm install
Results looked better, only some warmings
WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
After that I ran node node_modules/brunch/bin/brunch build and tried iex -S mix phoenix.server. It ran alright.
Cool, and yeah those warnings about fsevent always happen to me. Instead of it being quiet since it is a no-op on my platform, instead it is loud and always displays that warn, which is irritating…
1 Like
I had the same error message after letting Ubuntu upgrade itself. I created a new Elixir prorject and then compared the package.json
files. This showed that several of the brunch modules were out of date. I manually edit the version on these modules in my project and than ran npm install
.
That fixed it.
Thanks for the solution. I was getting the same error as well. What I did was write down the packages in package.json
, delete the package.json
file, and then do an npm install --save
of the packages in the original package.json
. After which I added the correct code for phoenix
and phoenix_html
packages.