1

I've created a new Laravel-project using composer

./composer.phar create-project laravel/laravel --prefer-dist ProjectName

Next, I've added the required packages through npm. I've already noticed the --save switch is necessary to make it work correctly:

npm install jquery --save
npm install bootstrap --save
npm install font-awesome --save

When I show the packages in this directory:

npm list --depth=0
@ /var/www/ProjectName
├── axios@0.16.2
├── bootstrap@3.3.7
├── bootstrap-sass@3.3.7
├── cross-env@5.0.5
├── font-awesome@4.7.0
├── jquery@3.2.1
├── laravel-mix@1.4.5
├── lodash@4.17.4
└── vue@2.4.4

Nothing is listed as extraneous.

Now, I'm trying to compile these assets (js and css) into 2 files, which are easy to include in the blade-template. The docs say I have to use npm run dev, but this fails with the most cryptic message you can ever imagine.

events.js:141
    throw er; // Unhandled 'error' event
    ^

Extras

  • Call stack:

    Error: spawn node_modules/webpack/bin/webpack.js ENOENT
        at exports._errnoException (util.js:907:11)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:189:32)
        at onErrorNT (internal/child_process.js:363:16)
        at nextTickCallbackWith2Args (node.js:511:9)
        at process._tickCallback (node.js:425:17)
        at Function.Module.runMain (module.js:443:11)
        at startup (node.js:140:18)
        at node.js:1043:3
    
  • The npm run dev command results in following command:

    cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
    
  • Versions:

    npm ERR! node -v v4.8.2
    npm ERR! npm -v 1.4.21
    

I've put the entire output online as well: output

Why isn't it possible to compile the assets? How can I fix this?

EDIT:

All right found it!

somehow i reinstalled nodejs to not have the legacy-version. These are the commmands I ran:

sudo apt-get remove nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get -y install nodejs
sudo apt-get install dh-autoreconf
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
npm install bootstrap --save
npm list --depth=0
npm run dev

1 Answers1

0

Try removing the contents of node_modules/

rm -Rfv your_project_path/node_modules/

then

npm install

Let me know if it helps.

Marco Santana
  • 121
  • 1
  • 13