Search code examples
javascriptnode.jsdeploymentweb-applicationsethereum

Getting error in while running nodeJS application in Ethereum


when I do npm run dev The following error comes up:-

rj24@rishi-g5:~/CrowdFunding-Ethereum$ sudo npm run dev [sudo] password for rj24:

[email protected] dev /home/rj24/CrowdFunding-Ethereum node server.js

(node:24992) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'access' of undefined at fileExists (/home/rj24/CrowdFunding-Ethereum/node_modules/next/dist/lib/file-exists.js:1:211) at verifyTypeScriptSetup (/home/rj24/CrowdFunding-Ethereum/node_modules/next/dist/lib/verifyTypeScriptSetup.js:1:3167) at DevServer.prepare (/home/rj24/CrowdFunding-Ethereum/node_modules/next/dist/server/next-dev-server.js:10:1908) at Object. (/home/rj24/CrowdFunding-Ethereum/server.js:13:5) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Function.Module.runMain (module.js:693:10) (node:24992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4) (node:24992) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


Solution

  • The library that you are using (next), is trying to use the fs Promises API, and this API is available only on node version 10 and above.

    Try running node -v to see the version of node you are currently using.

    If you have nvm installed you can "switch" to a different version of node running nvm use v10 or nvm use v11. If you don't have these versions installed you can install by running nvm install v10.