SyntaxError: Invalid or unexpected token when trying to run gulp - laravel

I am new to gulp but on a existing laravel project I needed to add some css I was told to update the app.sass and then run gulp to compile it. I tried to follow a guide called Compiling Assets (Laravel Elixir) to compile the sass file but ran into problems. To get everything installed correctly I updated our bootstrap.sh file in the vagrant setup to include nodejs, npm, gulp and laravel-elixir. Once the changes were made I loaded the vagrant box and I verified that I have the following versions.
[vagrant#localhost project-css]$ gulp -v
[18:12:38] CLI version 1.4.0
[18:12:38] Local version 3.9.1
[vagrant#localhost project-css]$ npm -v
3.10.10
[vagrant#localhost project-css]$ node -v
v6.11.1
When I try to run gulp I get
/vagrant/src/project-css/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:349
if (n <= 0 || state.length === 0 && state.end
SyntaxError: Invalid or unexpected token
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/vagrant/src/project-css/node_modules/through2/node_modules/readable-stream/readable.js:12:30)
The full project I'm working on is available on github at Rockefeller-css
Any suggestions would be appreciated.

I was able to resolve the issue on my own by adding the following to my bootstrap.sh file
rpm -ivh https://kojipkgs.fedoraproject.org//packages/http-parser/2.7.1/3.el7/x86_64/http-parser-2.7.1-3.el7.x86_64.rpm
yum install -y nodejs
Also after vagrant was finished loading and I was able to ssh into the box in a custom setup-vagrant.sh script that needed to be ran I was able to add the following command.
sudo npm install
Their was already a cd into the laravel project folder and their was a package.json file that existed. After that I was able to cd into the project folder and run gulp correctly.

Related

Laravel 8 fresh installation with livewire npm install && npm run dev error

When installing fresh Laravel 8.1 with livewire when in CLI i run npm run dev i got this i m new so please help me out?
> mix
[webpack-cli] /var/www/html/Am2/node_modules/laravel-mix/src/Mix.js:18
static _primary = null;
SyntaxError: Unexpected token =
at new Script (vm.js:83:7)
at NativeCompileCache._moduleCompile (/var/www/html/Am2/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
at Module._compile (/var/www/html/Am2/node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/var/www/html/Am2/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at module.exports (/var/www/html/Am2/node_modules/laravel-mix/setup/webpack.config.js:2:17)
Error
Need to update node version.
Ubuntu (Linux)
Run this command to update node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
after this close current terminal and open new one and run this command in PROJECT DIR
sudo npm install
npm run dev
Just try to upgrade your current node version
Current stable 15.5.1
you can upgrade it using brew in Mac-OS case:
brew install nvm
nvm install 15
nvm use 15

TypeError: require.extensions.hasOwnProperty is not a function

I am setting a gulp installation on windows 10 for laravel,After I installing a npm,python and node
and I installed the gulp also ,AfterThat i run the
gulp like
command,it shows the following error message , I dont know where i mistake
Here Versions I installed
npm
--6.9.0
node
--10.15.3
python
2.7.16
gulp
ClI Version
--2.1.0 Local Version
--3.9.1
And I also installed gulp globally using following command
npm install -g gulp
i checked the npm update using following command globally
npm install npm-check-updates -g
After all i execute the gulp command it shows following error
$ gulp like
C:\cygwin64\home\D-218\workspace\shima\src\node_modules\laravel-elixir\node_modules\require-dir\index.js:93
if (!require.extensions.hasOwnProperty(ext)) {
^
TypeError: require.extensions.hasOwnProperty is not a function
at requireDir (C:\cygwin64\home\D-218\workspace\shima\src\node_modules\laravel-elixir\node_modules\require-dir\index.js:93:37)
at Elixir (C:\cygwin64\home\D-218\workspace\shima\src\node_modules\laravel-elixir\index.js:2:27)
at Object. (C:\cygwin64\home\D-218\workspace\shima\src\tasks\admin.js:34:1)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
Try to update require-dir to version 0.3.2, after that remove node_modules, and npm install. Hope it helps.

Vue init webpack test - not creating project - strict mode error?

I have tried to create a project using
$ vue init webpack test
and got following error
/usr/local/lib/node_modules/vue-cli/bin/vue-init:60 let template =
program.args[0]
^ SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at
exports.runInThisContext (vm.js:53:16) at Module._compile
(module.js:374:25) at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32) at Function.Module._load
(module.js:301:12) at Function.Module.runMain (module.js:442:10) at
startup (node.js:136:18) at node.js:966:3
Unfortunatly, "test" directory is not created.
I am using Bash on Ubuntu on Windows 10 and the following NPM packages:
vue#2.5.2
vue-cli#2.9.1
node.js#0.0.0
npm 3.5.2
Perhaps node verison is too low.
update your node version using
npm install -g n
sudo n stable
sudo npm install npm -g
when you node -v find there is no change, but try to init vue project again.

Unexpected Token ... require('React') when running react-native run-ios

Trying to get code running from my groups repo.... everyone elses seems to install and run fine, but my setup is having issues. Not sure if this is a dependency issue or not.
Tried removing node / npm / nvm and reinstalling everything including code from repo. Still having issues...
React : 0.14.8
react-native-cli: 0.2.0
react-native: 0.24.0
also react-native-cli was installed globally
with npm install -g react-native-cli
command after install : react-native run-ios
getting
/node_modules/react-native/Libraries/react-native/react-native.js:121
...require('React'),
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Module._extensions..js (module.js:442:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at
node_modules/react-native/node_modules/babel-core/lib/transformation/file/options/option-manager.js:409:22
at Array.map (native)
In npm#3 subDependencies are installed at the same level of your project dependencies (./node_modules). My guess is the project is missing some dependencies to run the packager. If you haven't already done so, updgrade to npm#3 ($ npm install -g npm), delete your node_modules folder, then try again.
$ rm -rf node_modules && npm install

Gulp not running gulp-sass

I installed a new distro (Elementary OS 0.3 Freya 64 bits) on my PC and setting up my workflow I'm having a problem running the gulp-sass package. When I run the gulp command it return the error:
$ gulp
[10:26:06] Using file /var/www/html/projects/avanteweb.github.io/gulpfile.js
[10:26:06] Working directory changed to /var/www/html/projects/avanteweb.github.io
/var/www/html/projects/avanteweb.github.io/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:22
throw new Error('`libsass` bindings not found. Try reinstalling `node-sass
^
Error: `libsass` bindings not found. Try reinstalling `node-sass`?
at getBinding (/var/www/html/projects/avanteweb.github.io/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:22:11)
at Object.<anonymous> (/var/www/html/projects/avanteweb.github.io/node_modules/gulp-sass/node_modules/node-sass/lib/index.js:188:23)
at Module._compile (module.js:462:26)
at Object.Module._extensions..js (module.js:480:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:367:17)
at require (module.js:386:17)
at Object.<anonymous> (/var/www/html/projects/avanteweb.github.io/node_modules/gulp-sass/index.js:3:17)
at Module._compile (module.js:462:26)
I tried the answers on Try reinstalling node-sass on node 0.12? but it's still not working. How can I fix this issue?
Reading from other threads, this might work for you:
$ npm uninstall gulp-sass node-sass
$ npm install node-sass#1.0.3 # using an older version of node-sass
$ npm install gulp-sass
References:
Try reinstalling node-sass on node 0.12?
Install fails - Windows 2008 - Error: libsass bindings not found. Try reinstalling node-sass?
libsass bindings not found error on v1.3.1, v1.3.2

Resources