Can you show us what you have? Package.json and mix config. And can you run npm install?
Moved a Laravel 8 app to another domain and now 'npm run prod' is broken?
Hello all, I was wondering if someone can help me with a strange issue I've come across.
I've moved a copy of my Laravel 8 app to another domain on the same VPS and while the install seems to have worked perfectly (regarding functionality etc) I seem to have an issue when running npm run prod.
On the original domain I can run this without any issues. Having zipped an archive of the original app (as a backup), I've extracted it into the correct directory. The files are identical apart from the tweaks I've made to the .env file for the app name and database, as well as the app config file.
When I run npm run prod I get this error (server path and domain name removed):
[XXXXXXXXX@dXXXXXXXXX XXXXXXXXX]$ npm run prod
> @ prod /home/XXXXXXXXX/XXXXXXXXX.co.uk/XXXXXXXXX
> npm run production
> @ production /home/XXXXXXXXX/XXXXXXXXX.co.uk/XXXXXXXXX
> mix --production
internal/modules/cjs/loader.js:1032
throw err;
^
Error: Cannot find module '../package.json'
Require stack:
- /home/XXXXXXXXX/XXXXXXXXX.co.uk/XXXXXXXXX/node_modules/.bin/mix
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/home/XXXXXXXXX/XXXXXXXXX.co.uk/XXXXXXXXX/node_modules/.bin/mix:8:13)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/XXXXXXXXX/XXXXXXXXX.co.uk/XXXXXXXXX/node_modules/.bin/mix'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `mix --production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production 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! /home/XXXXXXXXX/.npm/_logs/2022-07-19T16_17_35_623Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ prod: `npm run production`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ prod 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! /home/XXXXXXXXX/.npm/_logs/2022-07-19T16_17_35_639Z-debug.log
When I checked the log, I got this:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/bin/node',
1 verbose cli '/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'prod'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'preprod', 'prod', 'postprod' ]
5 info lifecycle @~preprod: @
6 info lifecycle @~prod: @
7 verbose lifecycle @~prod: unsafe-perm in lifecycle true
8 verbose lifecycle @~prod: PATH: /home/XXXXXXXXX/.nvm/versions/node/v14.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXX/node_modules/.bin:/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/cpanel/composer/bin:/home/XXXXXXXXX/.local/bin:/home/XXXXXXXXX/bin
9 verbose lifecycle @~prod: CWD: /home/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXX
10 silly lifecycle @~prod: Args: [ '-c', 'npm run production' ]
11 silly lifecycle @~prod: Returned: code: 1 signal: null
12 info lifecycle @~prod: Failed to exec prod script
13 verbose stack Error: @ prod: `npm run production`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:315:20)
13 verbose stack at ChildProcess.<anonymous> (/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:315:20)
13 verbose stack at maybeClose (internal/child_process.js:1051:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid @
15 verbose cwd /home/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXX
16 verbose Linux 3.10.0-1160.42.2.vz7.184.10
17 verbose argv "/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/bin/node" "/home/XXXXXXXXX/.nvm/versions/node/v14.4.0/bin/npm" "run" "prod"
18 verbose node v14.4.0
19 verbose npm v6.14.5
20 error code ELIFECYCLE
21 error errno 1
22 error @ prod: `npm run production`
22 error Exit status 1
23 error Failed at the @ prod script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Unfortunately I'm not that technically minded when it comes to the 'behind the scenes' things - does anyone have any ideas why I'm getting this issue?
I've cleared all the caches etc, checked the permissions and the setup (inc php8.1) is identical to the original domain and they're both on the same VPS which is running AlmaLinux 8 with plenty of ram and CPUs - I just cannot find what is stopping it. Knowing me, its probably something really simple!
Thanks in advance for any help!
Seems like a platform issue. You could try deleting the package-lock.json and the node_modules directory then resinstall them with npm install.
There might be a platform setting you could use in the package.json file but I'm not too sure.
Please or to participate in this conversation.