Its a long story but I want to build ionic through php on my vagrant box.
npm run ionic:build 2>&1;
so <?php shell_exec('npm run ionic:build 2>&1;') ?>
I can run the command successfully through vagrant ssh
However when I run the task through php I get the following output.
> ionic-hello-world@ ionic:build /home/vagrant/Code/Laravel/hybrid
> ionic-app-scripts build
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! ionic-hello-world@ ionic:build: `ionic-app-scripts build`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! code ELIFECYCLE
npm ERR! errno -2
npm ERR! ionic-hello-world@ ionic:build: `ionic-app-scripts build`
npm ERR! Exit status -2
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:build 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/vagrant/.npm/_logs/2017-08-09T16_00_30_943Z-debug.log
Any ideas?
Besides that this is really, really a terrible idea?
Yeah, add --verbose
to the command, maybe we get some additional, helpful output.
You are in the correct directory?
Can you get ionic info
via that execution method please?
Why is it a terrible idea?
What if I have an application that wants to automate building ionic and also update the www folder through a cms.
It just feels wrong, your error message proves it, doesn’t it?
But please ignore that comment and respond to the rest. I will try to help you anyway.
To me it makes sense if I can get it to work.
npm info it worked if it ends with ok
npm verb cli [ '/usr/bin/nodejs',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'run',
npm verb cli 'ionic:build',
npm verb cli '--verbose' ]
npm info using npm@5.3.0
npm info using node@v5.0.0
npm verb run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
npm info lifecycle ionic-hello-world@~preionic:build: ionic-hello-world@
npm info lifecycle ionic-hello-world@~ionic:build: ionic-hello-world@
> ionic-hello-world@ ionic:build /home/vagrant/Code/Laravel/hybrid
> ionic-app-scripts build
npm verb lifecycle ionic-hello-world@~ionic:build: unsafe-perm in lifecycle true
npm verb lifecycle ionic-hello-world@~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/vagrant/Code/Laravel/hybrid/node_modules/.bin:/usr/bin
npm verb lifecycle ionic-hello-world@~ionic:build: CWD: /home/vagrant/Code/Laravel/hybrid
npm info lifecycle ionic-hello-world@~ionic:build: Failed to exec ionic:build script
npm verb stack Error: ionic-hello-world@ ionic:build: `ionic-app-scripts build`
npm verb stack spawn sh ENOENT
npm verb stack at exports._errnoException (util.js:860:11)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
npm verb stack at onErrorNT (internal/child_process.js:344:16)
npm verb stack at doNTCallback2 (node.js:450:9)
npm verb stack at process._tickCallback (node.js:364:17)
npm verb pkgid ionic-hello-world@
npm verb cwd /home/vagrant/Code/Laravel/hybrid
npm verb Linux 3.19.0-25-generic
npm verb argv "/usr/bin/nodejs" "/usr/local/bin/npm" "run" "ionic:build" "--verbose"
npm verb node v5.0.0
npm verb npm v5.3.0
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! ionic-hello-world@ ionic:build: `ionic-app-scripts build`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm info lifecycle ionic-hello-world@~ionic:build: Failed to exec ionic:build script
npm verb stack Error: ionic-hello-world@ ionic:build: `ionic-app-scripts build`
npm verb stack Exit status -2
npm verb stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
npm verb stack at emitTwo (events.js:87:13)
npm verb stack at EventEmitter.emit (events.js:172:7)
npm verb stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack at emitTwo (events.js:87:13)
npm verb stack at ChildProcess.emit (events.js:172:7)
npm verb stack at maybeClose (internal/child_process.js:818:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
npm verb stack at onErrorNT (internal/child_process.js:344:16)
npm verb stack at doNTCallback2 (node.js:450:9)
npm verb pkgid ionic-hello-world@
npm verb cwd /home/vagrant/Code/Laravel/hybrid
npm verb Linux 3.19.0-25-generic
npm verb argv "/usr/bin/nodejs" "/usr/local/bin/npm" "run" "ionic:build" "--verbose"
npm verb node v5.0.0
npm verb npm v5.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno -2
npm ERR! ionic-hello-world@ ionic:build: `ionic-app-scripts build`
npm ERR! Exit status -2
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ -2, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! /home/vagrant/.npm/_logs/2017-08-09T16_58_35_532Z-debug.log
Can you execute the command manually via SSH in that folder?
If I log into vagrant and this folder yes.
npm -v
via the php/shell thing?
Although I am not trying it through php shell_exec.
Ok, the “can you do it manually” was to check if it works with a normal user and environment.
The npm -v
via shell_exec to test if npm
can be used via this at all.
Are you logged in with the same user that is executing the PHP script?
That is weird when i run ionic info in the shell_exec() I get.
ERR: Your Node.js version is v5.0.0. Please update to the latest Node 6 LTS version (or latest Node).
Manually and in the script it says both 5.3.0
node -v I get v8.2.1 in both
Ok, so ionic info
via shell_exec is aborting with you are node 5.0.0
which is not true, right?
Run ionic info --verbose
via shell_exec.
same output
RR: Your Node.js version is v5.0.0. Please update to the latest Node 6 LTS version (or latest Node).
/usr/bin/node --version in the exec I get 5.0 - so I must have two versions installed.
1 Like
So I will need to find out how to remove use correct version or update this version. I will try to update my path or something
I have read many reports of pain attempting to use npm on vagrant due to lack of symlink support.
1 Like