'Zetta Error: Please verify that the package.json has a valid main entry

I have an issue about Zetta. This is the first time I'm using Zetta and I'm trying to do the 'hello-world' tutorial. When I try to run index.js, continuously getting this error:

node:internal/modules/cjs/loader:361
      throw err;
      ^

Error: Cannot find module '/home/dogac/Desktop/projects/hello-world/node_modules/zetta/zetta.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (node:internal/modules/cjs/loader:353:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (/home/dogac/Desktop/projects/hello-world/index.js:1:13)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32) {
  code: 'MODULE_NOT_FOUND',
  path: '/home/dogac/Desktop/projects/hello-world/node_modules/zetta/package.json',
  requestPath: 'zetta'
}

And here is my package.json file:

{
  "name": "hello-world",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "forest": "^0.19.6",
    "uuid": "^8.3.2",
    "zetta": "^0.0.3"
  },
  "devDependencies": {},
  "description": ""
}

I saw a lot of topics like mine, tried everything but couldn't solve. I would be very appreciated if someone can help. Thanks!



Solution 1:[1]

node:internal/modules/cjs/loader:361 throw err; ^

Error: Cannot find module '/Users/node_modules/express/server.js'. Please verify that the package.json has a valid "main" entry

fixed the above error - by making sure the express.js was added into my package.json as a dependencies.

"dependencies": { "ejs": "^3.1.6", "express-ejs": "^2.0.0", "express-ejs-layouts": "^2.5.1", "express.js": "^1.0.0" },

Solution 2:[2]

I had a similar issue, my approach was to use npm ci where ci stands for continuous integration to install the exact dependencies on my package.json file. However, a note should be taken that this command installs entire project dependencies and can not be employed for the installation of discrete dependencies. Added to what has already been mentioned, when npm ci is run, the node_modules if the exit is deleted first before installation began.

Nevertheless, I recommend you equally check and be sure the issue is not related to your package.json.

Here are the steps I took to solve the problem:

  • npm cache clean --force
  • npm ci
  • npm build

This same issue was raised and here was the response which the respondent described such an installation as a clean installation alternate solution proposed by respondent

Overall, this issue is just related to dependency faults.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tesla
Solution 2 NGUM BUKA FON NYUYDZE