Cannot find module '../package'

Running into an interesting issue with my Gatsby site which is deploying properly on Netlify at the moment. I installed the CLI because sometimes I can run dev and build locally without issue but when I push my changes to GitHub and Netlify does it’s build – it will fail. I figured the CLI tool can help me mitigate issues before I push code.

Currently if I run netlify dev I get the following:

◈ Netlify Dev ◈
◈ Starting Netlify Dev with gatsby
Waiting for localhost:8000.
> stallone.dev@1.0.1 start [local-user-folder]/stallone.dev/stallone.dev-netlify
> serve public/

module.js:550
    throw err;
    ^

Error: Cannot find module '../package'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> ([local-user-folder]/stallone.dev/stallone.dev-netlify/node_modules/.bin/serve:24:13)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! stallone.dev@1.0.1 start: `serve public/`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the stallone.dev@1.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     [local-user-folder]/.npm/_logs/2019-06-02T13_31_11_106Z-debug.log

Where that debug.log starts going haywire is here:

12 info lifecycle stallone.dev@1.0.1~start: Failed to exec start script
13 verbose stack Error: stallone.dev@1.0.1 start: `serve public/`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> ([local-user-folder].nvm/versions/node/v8.15.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> ([local-user-folder].nvm/versions/node/v8.15.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:915:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid stallone.dev@1.0.1
15 verbose cwd [local-user-folder]Dropbox/stallone.dev/stallone.dev-netlify
16 verbose Darwin 18.2.0
17 verbose argv "[local-user-folder].nvm/versions/node/v8.15.1/bin/node" "[local-user-folder].nvm/versions/node/v8.15.1/bin/npm" "run" "start"
18 verbose node v8.15.1
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error stallone.dev@1.0.1 start: `serve public/`
22 error Exit status 1
23 error Failed at the stallone.dev@1.0.1 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Could you let us know what version of netlify-dev, our CLI, and netlify-lambda (if you use that) you are using please? I thought we had gotten that situation fixed up in a recent version but if you’re up to date with the latest, and still seeing it let me know and I have a workaround I can share with you.

It smells a lot like this situation to me: https://github.com/netlify/netlify-lambda/issues/142

Hey fool! Thanks for replying!

netlify --version netlify-cli/2.11.19 darwin-x64 node-v8.15.1

Not using Netlify-lambda but you can see the entire repo here for reference.

hi! checking this out, thanks for sharing the repo. no idea as to cause yet

EDIT: i cannot replicate your exact error, all i get is a bunch of dots. anyway i think this is due to netlify dev being too smart and running your start script instead of your gatsby develop script. if you delete or rename that then netlify dev should work. we need to make its logic a little less magic.

here is netlify dev working with the start script removed (because we built in a preference for the start script)

1 Like

:clap: That worked! Thanks!

This is a clone of Egghead’s own Gatsby blog starter and to be honest I never use the start script. Maybe I should have and it would have alleviated any previous Netlify deployment issues. Either way hopefully now with this tool I should be able to solve any problems before deploying.

2 Likes

the lack of visibility into what script netlify dev picks is a design flaw on our part. its something i saw a while ago but never prioritized. we’ll fix it someday.