How to access .next/server on Vercel when running build:rss script:
{
"export": "next export",
"build": "next build && npm run export && npm run build:rss",
"build:rss": "node ./.next/server/scripts/build-rss.js",
"start": "next start",
}
Vercel throws error:
> node ./.next/server/scripts/build-rss.js
15:14:05.786 internal/modules/cjs/loader.js:968
15:14:05.786 throw err;
15:14:05.786 ^
15:14:05.786 Error: Cannot find module '/vercel/workpath0/.next/server/scripts/build-rss.js'
15:14:05.786 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
15:14:05.786 at Function.Module._load (internal/modules/cjs/loader.js:841:27)
15:14:05.786 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
15:14:05.786 at internal/main/run_main_module.js:17:47 {
whereas Netlify works just fine.
I had to change server to serverless in the build:rss script to make it work :)
Related
Whenever I try to run my app with npm start in the terminal, this is the error I get:
iteh-projekat#1.0.0 start
> NODE_ENV=production node ./dist/server.generated.js
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/Users/mihailomitrovic/Downloads/iteh_projekat/dist/server.generated.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Could someone help me with fixing this? The dist folder is empty, so I'm not sure what's happening. I've done npm install when pulling it from Github, since I'm working on it with friends for a uni project. Thank you!
I get a MODULE_NOT_FOUND error after successfully installing the external module "file" with npm. It appears in the project folder with all its files as usual, the dependencies in the json file are also there. It happens with every npm package. I already reinstalled npm and tried different LTS versions of npm. I double checked the json file that the dependencies are corret.
This is the error message:
phila#DESKTOP-68STT9S MINGW64 /g/My Drive/Work - Software/WebDevelopmentCourse/Web Development/introNPMNODE
$ node test.js
node:internal/modules/cjs/loader:959
throw err;
^
Error: Cannot find module 'file'
Require stack:
- G:\My Drive\Work - Software\WebDevelopmentCourse\Web Development\introNPMNODE\test.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Function.Module._load (node:internal/modules/cjs/loader:804:27)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (G:\My Drive\Work - Software\WebDevelopmentCourse\Web Development\introNPMNODE\test.js:1:12)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'G:\\My Drive\\Work - Software\\WebDevelopmentCourse\\Web Development\\introNPMNODE\\test.js'
]
}
This is the json file:
{
"name": "intronpmnode",
"version": "1.0.0",
"description": "test",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "phil",
"license": "ISC",
"dependencies": {
"core-util-is": "^1.0.3",
"file": "^0.2.2"
}
}
the javascript "test.js" file:
var file = require("file");
make sure you are pointing the node command to a file that exists on your file system and There are no spaces between words, delete node_modules and package-lock.json, re-install dependencies and restart your IDE.
If the error is not resolved, try to delete your and (not) files, re-run and restart your IDE.node_modules package-lock.json package.json npm install
delete node_modules and package-lock.json
rm -rf node_modules
rm -f package-lock.json
clean npm cache
npm cache clean --force
npm install
I have tried to run my node server multiple times I am getting this error, for this I tried to delete .next folder and build again after build complete it throws same error. It is running perfectly on my local machine.
`Could not find a valid build in the '${this.distDir}' directory! Try building your app with 'next build' before starting the server
Error: Could not find a valid build in the '/root/only4laughproject/.next' directory! Try building your app with 'next build' before starting the server.
at Server.readBuildId (/root/only4laughproject/node_modules/next-server/dist/server/next-server.js:435:23)
at new Server (/root/only4laughproject/node_modules/next-server/dist/server/next-server.js:44:29)
at module.exports (/root/only4laughproject/node_modules/next-server/index.js:4:10)
at module.exports (/root/only4laughproject/node_modules/next/dist/server/next.js:2:161)
at Object.<anonymous> (/root/only4laughproject/server.js:9:13)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
here is my package.json script
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "npm run-script build && cross-env NODE_ENV=production node server.js",
"go": "cross-env NODE_ENV=production node server.js"
}
on doing npm start command it is running next build command before project build finish it starts my server.js that's why this problem occur, I tried next build after build complete I hit node server.js. It resolve my issue.
I've updated Node from version 12.x.x to 14.16.0. After this I get serveral error messages when I try to start the server.
In the package.json I defined under the scripts object a key "start" with value "nodemon server.
"scripts": {
"test": "Hello World",
"start": "nodemon server"
In the Terminal I call npm start and get the following error:
npm ERR! missing script: start
I also tried node server. But that isn't successful too. The message is:
internal/modules/cjs/loader.js:883 throw err; ^
Error: Cannot find module
'C:\Users\Marco\Desktop\Studium\UndsoKram\server'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load
(internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
Have someone a idea how too fix that? Is it necessary to go back to node version 12.x.x.?
I am trying to start two servers using nodemon.
"scripts": {
"start": "node server.js && node serverpage.js"
},
I installed nodemon correctly and when I try to execute it I get the following error:
Error: Cannot find module 'C:\Users\puppe\Desktop\alles\Login-Projekt\login.js'
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Now the thing is that I can start both servers independently with no problems but they're failing to start together. Any ideas?