npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Error: Cannot find module './config.json'

When I run npm start or run dev I get this Error:

0 info it worked if it ends with ok

1 verbose cli [ ‘/usr/bin/node’, ‘/usr/bin/npm’, ‘start’ ]

2 info using npm@6.8.0

3 info using node@v11.1.0

4 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]

5 info lifecycle server@1.0.0~prestart: server@1.0.0

6 info lifecycle server@1.0.0~start: server@1.0.0

7 verbose lifecycle server@1.0.0~start: unsafe-perm in lifecycle true

8 verbose lifecycle server@1.0.0~start: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/zolile/Desktop/POS/node_modules/.bin:/home/zolile/.local/bin:/home/zolile/anaconda3/bin:/home/zolile/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

9 verbose lifecycle server@1.0.0~start: CWD: /home/zolile/Desktop/POS

10 silly lifecycle server@1.0.0~start: Args: [ ‘-c’, ‘node server.js’ ]

11 silly lifecycle server@1.0.0~start: Returned: code: 1 signal: null

12 info lifecycle server@1.0.0~start: Failed to exec start script

13 verbose stack Error: server@1.0.0 start: node server.js

13 verbose stack Exit status 1

13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)

13 verbose stack at EventEmitter.emit (events.js:182:13)

13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)

13 verbose stack at ChildProcess.emit (events.js:182:13)

13 verbose stack at maybeClose (internal/child_process.js:970:16)

13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:257:5)

14 verbose pkgid server@1.0.0

15 verbose cwd /home/zolile/Desktop/POS

16 verbose Linux 4.15.0-45-generic

17 verbose argv “/usr/bin/node” “/usr/bin/npm” “start”

18 verbose node v11.1.0

19 verbose npm v6.8.0

20 error code ELIFECYCLE

21 error errno 1

22 error server@1.0.0 start: node server.js

22 error Exit status 1

23 error Failed at the server@1.0.0 start script.

23 error This is probably not a problem with npm. There is likely additional logging output above.

24 verbose exit [ 1, true ]

npm run start is running node server.js which is failing. You can run node server.js yourself to confirm the problem is not with npm.

From the title you gave, I am guessing you have a line in server.js like:

var config = require("./config.json");

And that the path to that file is not correct, or the file does not exist.