Npm start error

Installing via npm, everything worked well up to the “npm start” command when I received an error.

Failure Logs

Output from npm start:

> company-admin@0.0.1 start
> node ./server.js

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

Error: Cannot find module 'dotenv'
Require stack:
- /home/williamw/company Admin/server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
    at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/williamw/company Admin/server.js:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/williamw/company Admin/server.js' ]
}
npm ERR! code 1
npm ERR! path /home/williamw/company Admin
npm ERR! command failed
npm ERR! command sh -c node ./server.js

Full debug log:

0 verbose cli [
0 verbose cli   '/home/williamw/.nvm/versions/node/v15.5.0/bin/node',
0 verbose cli   '/home/williamw/.nvm/versions/node/v15.5.0/bin/npm',
0 verbose cli   'start'
0 verbose cli ]
1 info using npm@7.3.0
2 info using node@v15.5.0
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/home/williamw/.nvm/versions/node/v15.5.0/lib/node_modules/npm/npmrc Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/home/williamw/company Admin/.npmrc Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:/home/williamw/.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:/home/williamw/.nvm/versions/node/v15.5.0/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 9ms
19 verbose npm-session 62313376f3428ae3
20 timing npm:load Completed in 17ms
21 timing command:run-script Completed in 50ms
22 timing command:start Completed in 53ms
23 verbose stack Error: command failed
23 verbose stack     at ChildProcess.<anonymous> (/home/williamw/.nvm/versions/node/v15.5.0/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
23 verbose stack     at ChildProcess.emit (node:events:376:20)
23 verbose stack     at maybeClose (node:internal/child_process:1063:16)
23 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
24 verbose pkgid company-admin@0.0.1
25 verbose cwd /home/williamw/company Admin
26 verbose Linux 4.14.200-116.320.amzn1.x86_64
27 verbose argv "/home/williamw/.nvm/versions/node/v15.5.0/bin/node" "/home/williamw/.nvm/versions/node/v15.5.0/bin/npm" "start"
28 verbose node v15.5.0
29 verbose npm  v7.3.0
30 error code 1
31 error path /home/williamw/company Admin
32 error command failed
33 error command sh -c node ./server.js
34 verbose exit 1

Context

  • OS: Amazon Linux AMI 2018.03
  • Database Dialect: MySQL
  • Node: 15.5.0
  • npm: 7.3.0

Hello @William_W,

Welcome to the ForestAdmin community and thank you for sharing your issue with us!

In order to assist you, I would need some additional information.

  • Could you please check that you run the npm install -s command and that it was successful?
  • If yes, can you please run ls command in the project root folder and confirm that you have the node_modules folder present?

Thank you

I didn’t notice any error from npm install -s the first time I ran it, but I ran it again after your suggestion and it ran successfully and the node_modules directory is there. Everything works fine now, thanks. :woman_shrugging:

1 Like