Error: Cannot find module ‘/opt/render/project/src/index.js’

I changed the root directory to client/src, so the Error: Cannot find module ‘/opt/render/project/src/index.js’ disappear but shows other errors in the screenshot. is there anyone who can help me this? thanks.

==> Deploying…
Nov 4 07:59:42 AM ==> Build uploaded in 9s
Nov 4 07:59:42 AM ==> Build successful :tada:
Nov 4 08:00:14 AM ==> Using Node version 14.17.0 (default)
Nov 4 08:00:14 AM ==> Docs on specifying a Node version: Setting Your Node.js Version | Render Docs
Nov 4 08:00:14 AM ==> Running ‘node index.js’
Nov 4 08:00:14 AM (node:45) Warning: To load an ES module, set “type”: “module” in the package.json or use the .mjs extension.
Nov 4 08:00:14 AM (Use node --trace-warnings ... to show where the warning was created)
Nov 4 08:00:14 AM /opt/render/project/src/client/src/index.js:1
Nov 4 08:00:14 AM import React from ‘react’;
Nov 4 08:00:14 AM ^^^^^^
Nov 4 08:00:14 AM
Nov 4 08:00:14 AM SyntaxError: Cannot use import statement outside a module
Nov 4 08:00:14 AM at wrapSafe (internal/modules/cjs/loader.js:984:16)
Nov 4 08:00:14 AM at Module._compile (internal/modules/cjs/loader.js:1032:27)
Nov 4 08:00:14 AM at Object.Module._extensions…js (internal/modules/cjs/loader.js:1097:10)
Nov 4 08:00:14 AM at Module.load (internal/modules/cjs/loader.js:933:32)
Nov 4 08:00:14 AM at Function.Module._load (internal/modules/cjs/loader.js:774:14)
Nov 4 08:00:14 AM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Nov 4 08:00:14 AM at internal/main/run_main_module.js:17:47
Nov 4 08:00:21 AM ==> Using Node version 14.17.0 (default)
Nov 4 08:00:21 AM ==> Docs on specifying a Node version: Setting Your Node.js Version | Render Docs
Nov 4 08:00:21 AM ==> Running ‘node index.js’
Nov 4 08:00:21 AM (node:51) Warning: To load an ES module, set “type”: “module” in the package.json or use the .mjs extension.
Nov 4 08:00:21 AM (Use node --trace-warnings ... to show where the warning was created)
Nov 4 08:00:21 AM /opt/render/project/src/client/src/index.js:1
Nov 4 08:00:21 AM import React from ‘react’;
Nov 4 08:00:21 AM ^^^^^^
Nov 4 08:00:21 AM
Nov 4 08:00:21 AM SyntaxError: Cannot use import statement outside a module
Nov 4 08:00:21 AM at wrapSafe (internal/modules/cjs/loader.js:984:16)
Nov 4 08:00:21 AM at Module._compile (internal/modules/cjs/loader.js:1032:27)
Nov 4 08:00:21 AM at Object.Module._extensions…js (internal/modules/cjs/loader.js:1097:10)
Nov 4 08:00:21 AM at Module.load (internal/modules/cjs/loader.js:933:32)
Nov 4 08:00:21 AM at Function.Module._load (internal/modules/cjs/loader.js:774:14)
Nov 4 08:00:21 AM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Nov 4 08:00:21 AM at internal/main/run_main_module.js:17:47

Hi,

The logs you’re using the current Render Node runtime default:

Nov 4 08:00:14 AM ==> Using Node version 14.17.0 (default)
Nov 4 08:00:14 AM ==> Docs on specifying a Node version: https://render.com/docs/node-version

I’d expect you’ve been developing/testing on a newer version of Node. Maybe as a first step, set your Node version to the same one you use locally.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.