stuart-b
4/17/2019 - 10:14 AM

Node version issues

If you are having problems with node versions in a project you can have npm run them in the container, eg by adding this to your Makefile:

make ddev-gulp-build:
    # Run gulp build from the folder where your package.json is, within node modules, specifying the path to the gulpfile within the container.
    ddev exec bash -c './themes/THEMENAME/align/assets/src/node_modules/gulp/bin/gulp.js build --gulpfile /var/www/html/web/themes/custom/align/assets/src/gulpfile.js'

make ddev-gulp-watch:
    # Run gulp watch from the folder where your package.json is, within node modules, specifying the path to the gulpfile within the container.
    # Note that you won't see the 'recompile' or errors like this unfortunately. To get those, do `ddev ssh` and run the below command within quotes.
    ddev exec bash -c './themes/THEMENAME/align/assets/src/node_modules/gulp/bin/gulp.js watch --gulpfile /var/www/html/web/themes/custom/align/assets/src/gulpfile.js'

Then your npm would be run from within the container to initially install

make ddev-npm-install:
    # Remove package lock file and node modules for reinstall.
    ddev exec 'rm ./themes/THEMENAME/align/assets/src/package-lock.json'
    ddev exec 'rm -rf ./themes/THEMENAME/align/assets/src/node_modules'
    # Reinstall using node version within container.
    ddev exec bash -c 'cd ./themes/THEMENAME/align/assets/src/ && npm install'