OS: Debian 9 (stretch)
Saved Global npm install:
Building a static webapp with Next framework, npm run dev
works fine in localhost:3000 with package.json:
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
When building for deploy alone with npm run build
this happens:
> Failed to build { Error: (client) ./pages/index.js Module not found: Error: Can't resolve 'react' in 'path/to/pages' (......) }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/jp/.npm/_logs/2019-01-19T13_55_25_781Z-debug.log
I managed to build it yesterday, by reinstalling all the tech pile and giving su permission to my user (solution that's not working today again...). But when deployed with now
, somehow there's a problem with the path to index.js, because the url now
access can't find "./pages/index.js" and when redirected it displays the index.js in plain text instead of render the code.
SSR maybe? Trying to get my head around all this...
The same project was builded in a macOsX and deployed also with now and things worked perfectly.
So, what the hell mannn?
Installed and re-installed all the libs and main techs. Everything under the user and with suited priviledges. Recriated everything from zero in new location. Studied Next and Now's docs, as long as React's...
The closest I got to resolve the react module was with https://webpack.js.org/configuration/resolve/, but there's not a
module.exports = {
//...
resolve: {
module: ['react']
}
};
or something like that.
After all the troubleshooting, my logic is:
1 The code is fine, as it compiles and runs smoothly on other stations;
2 Maybe there's something to do with my compilation in Debian/Linux;
Can't go any further. Any help, thanks a lot.
dependencies
section of your project'spackage.json
) or installed globally (i.e. by runningnpm install --global react
)?