Laravel Mix: Update a Node.js dependency
Asked Answered
T

3

23

I am trying to compile webpack configuration files with Laravel Mix.

Following webpack episode on Laracasts Vue 2 series,

// Scripts

  "scripts": {
    "dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
....

// mix
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();

When I run $ npm run dev, I get an error:

npm ERR! Exit status 1

npm ERR! Failed at the @ dev script 'node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.

// Running

npm ERR! node v4.4.5
npm ERR! npm v2.15.5

// The error points to
let extractPlugin = new plugins.ExtractTextPlugin(
/Users/User/Code/project/node_modules/laravel-mix/setup/webpack.config.js:126

The issue seems to be update a Node.js dependency: https://github.com/JeffreyWay/laravel-mix/issues/264

How do I update the Node.js dependency?

I am trying:

$ brew upgrade node : Error = node not installed
$ node -v = 2.15.5
$ npm -v = 4.4.5
$ brew install node // installs but throws error

Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
  rm '/usr/local/bin/node'

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node

Possible conflicting files are:
/usr/local/bin/node
...

**$ brew upgrade node // says node 7.5.0 already installed**
$ npm run dev // same error
$ node -v = 4.4.5

I also ran $ brew install node which installed, but I got an error:

Error: The brew link step did not complete successfully.
The formula built, but is not symlinked into /usr/local.
Could not symlink bin/node.
Target /usr/local/bin/node
already exists. You may want to remove it:
rm '/usr/local/bin/node'

To force the link and overwrite all conflicting files:

brew link --overwrite node

To list all files that would be deleted:

brew link --overwrite --dry-run node
Tagore answered 6/2, 2017 at 13:13 Comment(7)
Tried a brew upgrade node ?Mina
Yeah mentioned that just at the end, getting node not installed but if I run node -v I get 4.4.5Tagore
try brew unlink node --force && brew uninstall node - then try installing it again, can try brew install node@6Mina
Installed from nodejs.org source, npm now 4.1.2 and node is 7.5.0 $ npm run dev = new error module.js:472 throw err; ^ Error: Cannot find module 'autoprefixer' $npm install autoprefixerTagore
1 year later I have this on OSX: $ brew upgrade node Error: node 9.11.1 already installed -- $ sudo ln -sf /usr/local/n/versions/node/9.11.1/bin/node /usr/bin/node ln: /usr/bin/node: Operation not permittedPalace
Why is operating not permitted? Try running sudo, or sudo su. Are you on mac os or linux?Tagore
Also, those commands seem like overkill. Can you not update from the command line as my instructions? I got it working eventually.Tagore
T
-3

I installed Node.js again from nodejs.org, rewriting old files.

However this actually downgraded npm from 4.4.5 to 4.1.2... Node.js was 2.15.5 and is now 7.5.0.

I also had to install a few modules: $ npm install autoprefixer

$ npm run dev // works now
Tagore answered 6/2, 2017 at 14:12 Comment(3)
how did you do that?... could you explain more , I had the same problem and i did not find any solution uptill now .Comprise
Had to update node and npm and then there was a bunch of missing dependencies such as autoprefixer...it told me everyone one to download that was missing just a matter of npm install missingdependency there was only 2-3 as far as I can remebmer. Did you get it?Tagore
You should be able to just run npm install and it will install all the missing dependencies in your package.json fileYeasty
T
2

you can delete your node modules folder in your laravel project.

after that run :

npm install - g npm

this command will reinstall the node modules folder with upgrading node files. next, you can try and run

npm run dev

and you can also run

npm update

to update your node

hope this answer will help

Tafilelt answered 9/7, 2020 at 14:25 Comment(0)
F
0

Im Using Windows 10 You can Download NVM for node it stands for node version manager after you set it up, type this to your cmd

nvm version
nvm install node {version of node you want}
nvm use {version of node}

hope this works for you because it works for me

Fluorspar answered 2/6, 2020 at 5:4 Comment(0)
T
-3

I installed Node.js again from nodejs.org, rewriting old files.

However this actually downgraded npm from 4.4.5 to 4.1.2... Node.js was 2.15.5 and is now 7.5.0.

I also had to install a few modules: $ npm install autoprefixer

$ npm run dev // works now
Tagore answered 6/2, 2017 at 14:12 Comment(3)
how did you do that?... could you explain more , I had the same problem and i did not find any solution uptill now .Comprise
Had to update node and npm and then there was a bunch of missing dependencies such as autoprefixer...it told me everyone one to download that was missing just a matter of npm install missingdependency there was only 2-3 as far as I can remebmer. Did you get it?Tagore
You should be able to just run npm install and it will install all the missing dependencies in your package.json fileYeasty

© 2022 - 2024 — McMap. All rights reserved.