Do you want to request a feature or report a bug?
Bug
What is the current behaviour?
I made a new project with preact create simple test
I can run it with npm run start
It works all nicely. I stop the server to install something from npm, or I just stop the server and then try start it again with npm run start and it tunes me this:
Build failed!
✖ ERROR ./node_modules/preact-cli/lib/lib/entry.js
Module not found: Error: Can't resolve 'preact-cli-entrypoint' in '/Applications/XAMPP/xamppfiles/htdocs/privacyDash/testFinal/try/node_modules/preact-cli/lib/lib'
@ ./node_modules/preact-cli/lib/lib/entry.js 15:25-57 21:27-59 25:17-65
@ multi ./node_modules/preact-cli/lib/lib/entry webpack-dev-server/client webpack/hot/dev-server
Like so out of the blue. I don't know how to fix it other than starting a new project, copying over my code and carrying on like that, but it's getting annoying now, haha. Am I doing something totally dumb? I've also tried removing the node modules and reinstalling with, I tried with npm and yarn.
If the current behaviour is a bug, please provide the steps to reproduce.
I made a new project with preact create simple test
I can run it with npm run start
It works all nicely. I stop the server and then try start it again with npm run start it throws an error
What is the expected behaviour?
No Error
Please mention other relevant information.
I can't reproduce this error in my local machine. It works fine for me. Can you please test it out once more and check if you are still getting this error or not.
I hadn't changed into the created directory before running the command, just in case anyone else comes across this!
Ah, oops! Thanks for sharing!
Global packages make for weird edge cases like that, which is why I personally don't recommend them. 😅
Good catch! Make sure you're in the directory with your package.json folks :)
Just for more information.
This error occurs by running from the wrong directory even with no global packages.
Also, make sure that you didn't add an empty src directory without moving index.js inside of it. That's what I did to throw this error.
Installed preact-cli globally
Created a new app with preact create simple foldername
cd into foldername
ran npm run start
Got this exact error. Is the simple template missing something?
I got this error when adding a preact.config.js
@tomsoderlund If you're modifying webpack aliases you need to merge with the existing ones to stop the error:
export default (config) => {
config.resolve.alias = {
react: "preact/compat",
"react-dom": "preact/compat",
...config.resolve.alias,
};
}
Most helpful comment
@tomsoderlund If you're modifying webpack aliases you need to merge with the existing ones to stop the error: