Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module 'node-sass' - Fresh laravel 5.4 install #226

Closed
sameerxanand opened this issue Jan 29, 2017 · 15 comments
Closed

Cannot find module 'node-sass' - Fresh laravel 5.4 install #226

sameerxanand opened this issue Jan 29, 2017 · 15 comments

Comments

@sameerxanand
Copy link

sameerxanand commented Jan 29, 2017

I just created a fresh Laravel 5.4 project using Laravel Homestead on a Windows machine. I ran npm install successfully, but am running into issues with npm run dev. Here is my output:


Module build failed: Error: Cannot find module 'node-sass'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/CSE356/node_modules/sass-loader/index.js:4:12)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:129:2)
    at NormalModule.build (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:180:15)
    at Compilation.buildModule (/home/vagrant/Code/CSE356/node_modules/webpack/lib/Compilation.js:127:10)

 @ ./resources/assets/sass/app.scss 4:14-248
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

 error  in ./resources/assets/sass/app.scss

Module build failed: Error
    at /home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:141:35
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:170:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:27:11)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:129:2)
    at NormalModule.build (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:180:15)
    at Compilation.buildModule (/home/vagrant/Code/CSE356/node_modules/webpack/lib/Compilation.js:127:10)
    at moduleFactory.create (/home/vagrant/Code/CSE356/node_modules/webpack/lib/Compilation.js:404:9)
    at /home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:242:4
    at /home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:93:13
    at /home/vagrant/Code/CSE356/node_modules/tapable/lib/Tapable.js:204:11
    at NormalModuleFactory.<anonymous> (/home/vagrant/Code/CSE356/node_modules/webpack/lib/CompatibilityPlugin.js:51:4)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/vagrant/Code/CSE356/node_modules/tapable/lib/Tapable.js:208:13)
    at onDoneResolving (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:68:11)
    at onDoneResolving (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:189:6)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)

 error

/home/vagrant/Code/CSE356/node_modules/extract-text-webpack-plugin/loader.js?{"id":1,"omit":1,"remove":true}!/home/vagrant/Code/CSE356/node_modules/style-loader/index.js!/home/vagrant/Code/CSE356/node_modules/css-loader/index.js!/home/vagrant/Code/CSE356/node_modules/postcss-loader/index.js!/home/vagrant/Code/CSE356/node_modules/resolve-url-loader/index.js!/home/vagrant/Code/CSE356/node_modules/sass-loader/index.js?sourceMap&precision=8!/home/vagrant/Code/CSE356/resources/assets/sass/app.scss doesn't export content
                                                                                                   Asset      Size  Chunks                    Chunk Names
       /js/app.js   1.16 MB       0  [emitted]  [big]  /js/app
mix-manifest.json  32 bytes          [emitted]

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v7.4.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! @ 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`
npm ERR! Exit status 2
npm ERR!
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'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     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
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/Code/CSE356/npm-debug.log
vagrant@homestead:~/Code/CSE356$

I have not modified the original package.json or webpack.mix.js files.

@sameerxanand
Copy link
Author

I also get this error:

              ERROR  Failed to compile with 3 errors

 error  in ./resources/assets/sass/app.scss

Module build failed: Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/CSE356/node_modules/node-sass/vendor'
    at Object.fs.readdirSync (fs.js:871:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/CSE356/node_modules/node-sass/lib/extensions.js:122:13)
    at foundBinariesList (/home/vagrant/Code/CSE356/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/CSE356/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/CSE356/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/CSE356/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/CSE356/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/vagrant/Code/CSE356/node_modules/sass-loader/index.js:4:12)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:13:17)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18

 @ ./resources/assets/sass/app.scss 4:14-248
 @ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

 error  in ./resources/assets/sass/app.scss

Module build failed: Error
    at /home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:141:35
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:364:11
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:170:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:27:11)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:165:10)
    at /home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:173:18
    at loadLoader (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/loadLoader.js:36:3)
    at iteratePitchingLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:169:2)
    at runLoaders (/home/vagrant/Code/CSE356/node_modules/loader-runner/lib/LoaderRunner.js:362:2)
    at NormalModule.doBuild (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:129:2)
    at NormalModule.build (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModule.js:180:15)
    at Compilation.buildModule (/home/vagrant/Code/CSE356/node_modules/webpack/lib/Compilation.js:127:10)
    at moduleFactory.create (/home/vagrant/Code/CSE356/node_modules/webpack/lib/Compilation.js:404:9)
    at /home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:242:4
    at /home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:93:13
    at /home/vagrant/Code/CSE356/node_modules/tapable/lib/Tapable.js:204:11
    at NormalModuleFactory.<anonymous> (/home/vagrant/Code/CSE356/node_modules/webpack/lib/CompatibilityPlugin.js:51:4)
    at NormalModuleFactory.applyPluginsAsyncWaterfall (/home/vagrant/Code/CSE356/node_modules/tapable/lib/Tapable.js:208:13)
    at onDoneResolving (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:68:11)
    at onDoneResolving (/home/vagrant/Code/CSE356/node_modules/webpack/lib/NormalModuleFactory.js:189:6)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)

 error

/home/vagrant/Code/CSE356/node_modules/extract-text-webpack-plugin/loader.js?{"id":1,"omit":1,"remove":true}!/home/vagrant/Code/CSE356/node_modules/style-loader/index.js!/home/vagrant/Code/CSE356/node_modules/css-loader/index.js!/home/vagrant/Code/CSE356/node_modules/postcss-loader/index.js!/home/vagrant/Code/CSE356/node_modules/resolve-url-loader/index.js!/home/vagrant/Code/CSE356/node_modules/sass-loader/index.js?sourceMap&precision=8!/home/vagrant/Code/CSE356/resources/assets/sass/app.scss doesn't export content
                                                                                                   Asset      Size  Chunks                    Chunk Names
       /js/app.js   1.16 MB       0  [emitted]  [big]  /js/app
mix-manifest.json  32 bytes          [emitted]

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! @ 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`
npm ERR! Exit status 2
npm ERR!
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'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     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
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/Code/CSE356/npm-debug.log
vagrant@homestead:~/Code/CSE356$

@sameerxanand sameerxanand changed the title Cannot find module 'node-sass' Cannot find module 'node-sass' - Fresh laravel 5.4 install Jan 29, 2017
@budi7
Copy link

budi7 commented Jan 30, 2017

so. here we waiting for the solution. Found the same problem here. anyone?

@JeffreyWay
Copy link
Collaborator

JeffreyWay commented Jan 30, 2017

It should install node-sass for you automatically, but if it failed for some reason, do:

npm install node-sass

@sameerxanand
Copy link
Author

To other people with similar issues, maybe this can help:

I had an issue when running npm install node-sass

So I ran npm install node-sass --no-bin-links and had no issues. Then I was able to run npm run dev with no issues.

Thanks for the help Jeffrey!

@M165437
Copy link

M165437 commented Nov 10, 2017

I solved the issue by deleting the package-lock.json file, the node_modules folder and npm install

$ rm package-lock.json
$ rm -rf node_modules
$ npm install

@ululajib
Copy link

Please help me ...

npm run dev

@ dev /var/www/html/screp
npm run development

@ development /var/www/html/screp
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

95% emitting

ERROR Failed to compile with 1 errors 00:33:59

This dependency was not found:

  • /var/www/html/screp/resources/assets/sass/app.scss in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

To install it, you can run: npm install --save /var/www/html/screp/resources/assets/sass/app.scss
Asset Size Chunks Chunk Names
/js/app.js 4.12 kB 0 [emitted] /js/app

ERROR in ./resources/assets/js/app.js
Module build failed: ReferenceError: Unknown plugin "transform-object-rest-spread" specified in "base"t > 0, attempted to resolve relative to "/var/www/html/screp/resources/assets/js"
at /var/www/html/screp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
> at Array.map ()
> at Function.normalisePlugins (/var/www/html/screp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
> at OptionManager.mergeOptions (/var/www/html/screp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
> at OptionManager.init (/var/www/html/screp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
> at File.initOptions (/var/www/html/screp/node_modules/babel-core/lib/transformation/file/index.js:212:65)
> at new File (/var/www/html/screp/node_modules/babel-core/lib/transformation/file/index.js:135:24)
> at Pipeline.transform (/var/www/html/screp/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
> at transpile (/var/www/html/screp/node_modules/babel-loader/lib/index.js:50:20)
> at /var/www/html/screp/node_modules/babel-loader/lib/fs-cache.js:118:18
> at ReadFileContext.callback (/var/www/html/screp/node_modules/babel-loader/lib/fs-cache.js:31:21)
> at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:437:13)
@ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

ERROR in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss>
Module not found: Error: Can't resolve 'css-loader' in '/var/www/html/screp'
@ multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

@mu345077
Copy link

mu345077 commented Feb 6, 2018

copy node-sass folder from any other node_modules and npm install. It works for me.

@lukebtaylor
Copy link

lukebtaylor commented Apr 4, 2018

Try running

npm cache verify

Before running

npm install

Then see if that takes care of your issue.

@shubhamkandiyal
Copy link

Just install node-sass with sudo

Like:

sudo -s

After Getting Permission of Super User

sudo npm install node-sass

After install node-sass. Please Try Again to Run Server.

@sameerxanand
Copy link
Author

Another issue I've come across recently... As you update your node version as new releases come out, you may have to delete your node_modules directory and re-install your dependencies.

@PharaonicDev
Copy link

write these
npm install style-loader css-loader autoprefixer-loader sass-loader node-sass --save-dev

@mu345077
Copy link

npm install node-sass.

@nrifki
Copy link

nrifki commented Jul 21, 2018

@AboBakr11 it worked for me but only when I used postcss-loader instead of autoprefixer-loader

@ralexandre75
Copy link

npm install node-sass
work for me !!!
thanks !

@raydacosta
Copy link

Senhores, só para ver se agrega ai para voces. Depois de executar os comandos abaixo FUNCIONOU! Usando Ubuntu

sudo -s
sudo npm cache verify
sudo rm package-lock.json
sudo rm -rf node_modules
sudo npm install
sudo npm install node-sass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests