找一天了还是没找到解决的办法 error in ./resources/Sass/app.scss Module build failed (from ./node_modules/Sass-loader/lib/loader.js): NoSuchMethodError: method not found: 'pathToFileURL' (url.pathToFileURL is not a function)

环境是 win10系统,教程里的 lc-homestead-6.4.1-2019072300 Homestead 虚拟机。

找一天了还是没找到解决的办法 error  in ./resources/sass/app.scss  Module build failed (from ./node_modules/sass-loader/lib/loader.js): NoSuchMethodError: method not found: 'pathToFileURL' (url.pathToFileURL is not a function)

找一天了还是没找到解决的办法 error  in ./resources/sass/app.scss  Module build failed (from ./node_modules/sass-loader/lib/loader.js): NoSuchMethodError: method not found: 'pathToFileURL' (url.pathToFileURL is not a function)

找一天了还是没找到解决的办法 error  in ./resources/sass/app.scss  Module build failed (from ./node_modules/sass-loader/lib/loader.js): NoSuchMethodError: method not found: 'pathToFileURL' (url.pathToFileURL is not a function)

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 18

执行yarn install了吗?

4年前 评论
bing_ (楼主) 4年前

@axkeson 每次一到
$ yarn install --no-bin-links
$ yarn add cross-env
$ npm run dev
$ npm run watch-poll
我都好害怕,一会再到这里,我该怎么办?

4年前 评论
axkeson 4年前
bing_ (作者) (楼主) 4年前
axkeson 4年前
bing_ (作者) (楼主) 4年前

跟着教程走,重装了虚拟机,虚拟机启动成功后
$ cd ~/Code
$ composer create-project laravel/laravel weibo --prefer-dist "5.8.*"
完成之后,访问 http://homestead.test
看到的是 No input file specified.

file

file

我真的搞不懂这是为什么。因为没升级之前,这第一步我都是成功的。这个问题我可以解决。我先解决这个问题。我要把跟教程走出现的所有问题都记录下来。

4年前 评论
axkeson 4年前
bing_ (作者) (楼主) 4年前
Summer 4年前
bing_ (作者) (楼主) 4年前
wengoo 4年前

file
Laravel

一直就这样:
vagrant@homestead:~$ vagrant plugin install vagrant-winnfsd
Invalid gemspec in [/usr/share/rubygems-integration/all/specifications/rbnacl-libsodium.gemspec]: stack level too deep

vagrant plugin install vagrant-winnfsd 又安装不了了。
如果可以不放弃,谁愿意放弃开启 NFS 解决站点响应缓慢。

4年前 评论
axkeson 4年前
Summer 4年前
bing_ (作者) (楼主) 4年前

@bing_ 首先你要清楚vagrant-winnfsd 是干嘛的,它是vagrant 的插件你不应该在虚拟机里装吧

4年前 评论
bing_ (楼主) 4年前
axkeson (作者) 4年前

亲,建议你更换电脑哦。买 mac book 吧,早买早享受。你买了拿到手的时候,只会后悔自己为什么没有早点买。

4年前 评论
bing_ (楼主) 4年前
lianglunzhong (作者) 4年前

我又走到这里了,提心吊胆的执行 $ yarn install --no-bin-links
结果如下:
file
vagrant@homestead:~/Code/weibo$ yarn install --no-bin-links
yarn install v1.12.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.0.7: The platform "linux" is incompatible with this module.
info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.0.7: The engine "node" is incompatible with this module. Expected version "^8.16.0 || ^10.6.0 || >=11.0.0". Got "8.12.0"
[3/4] Linking dependencies...
warning " > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
warning Your current version of Yarn is out of date. The latest version is "1.17.3", while you're on "1.12.3".
info To upgrade, run the following command:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
Done in 182.23s.

接下来,我要不要升级yarn?

4年前 评论

ERROR in ./resources/assets/sass/app.scss
Module build failed (from ./node_modules/css-loader/index.js):+1:
我也遇到一模一样的问题有人解决了吗?好心塞重装环境还是这样2天了已经

4年前 评论
bing_ (楼主) 4年前
bing_ (楼主) 4年前

忽略上面的警告,我继续执行命令 $ yarn add cross-env
结果如下:
file
vagrant@homestead:~/Code/weibo$ yarn add cross-env
yarn add v1.12.3
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.9: The platform "linux" is incompatible with this module.
info "fsevents@1.2.9" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.0.7: The platform "linux" is incompatible with this module.
info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.0.7: The engine "node" is incompatible with this module. Expected version "^8.16.0 || ^10.6.0 || >=11.0.0". Got "8.12.0"
[3/4] Linking dependencies...
warning " > sass-loader@7.1.0" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
error An unexpected error occurred: "EIO: i/o error, symlink '../../../parser/bin/babel-parser.js' -> '/home/vagrant/Code/weibo/node_modules/@babel/core/node_modules/.bin/parser'".
info If you think this is a bug, please open a bug report with the information provided in "/home/vagrant/Code/weibo/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
vagrant@homestead:~/Code/weibo$

接着我该怎么办?升级yarn吗?

4年前 评论

@bing_ 问答:yarn install --no-bin-links 报错 看下这篇文章能不能帮到你

4年前 评论
bing_ (楼主) 4年前

我执行了以下命令,都报同一个错。
$ yarn upgrade v1.17.3 【升级yarn,报错】
删除 “package.json ”文件“scripts” 里的 “cross-env” ,
重新再运行 $ yarn upgrade v1.17.3 【失败,报同一个错】
$ rm -rf node_modules
$ yarn upgrade v1.17.3 【执行失败,报下面同一个错】
file

error An unexpected error occurred: "EIO: i/o error, symlink '../../../parser/bin/babel-parser.js' -> '/home/vagrant/Code/weibo/node_modules/@babel/core/node_modules/.bin/parser'".

4年前 评论

问题已解决。
file

现在总结一下执行过程,最后再总结解决问题的过程:
按教程顺序,执行命令:
$ yarn install --no-bin-links 【警告,需要升级yarn。忽略,执行下一条命令】
$ yarn add cross-env 【报以下错误】
file

$ yarn upgrade v1.17.3 【升级yarn,执行失败,报上面同一个错误】
删除 “package.json ”文件“scripts” 里的 “cross-env” ,
$ yarn upgrade v1.17.3 【重新升级,失败,报同一个错误】
$ rm -rf node_modules 【删除node_modules 】
$ yarn config set registry https://registry.yarnpkg.com 【用yarn镜像】
得到此贴回复中的启发:
问答:yarn install --no-bin-links 是什么意思?
$ yarn upgrade v1.17.3 --no-bin-links 【用这个方法升级yarn。成功】
$ yarn add cross-env --no-bin-links 【成功保存了1个新的依赖。】
此文件 resources/sass/app.scss 只留下下面这行,为安全起见,我选择注释其它的。
// Bootstrap
@import '~bootstrap/scss/bootstrap';
$ npm run dev 【失败,报上面同样的错】
$ npm run dev --no-bin-links 【执行成功】
control+c 退出
$ npm run watch-poll 【执行成功!】

总结解决问题的方案(建议版):
当我们跟着教程操作完下面这一步的时候
$ yarn install --no-bin-links

开始:
1)删除 “package.json ”文件“scripts” 里的 “cross-env” 。

2)$ rm -rf node_modules 【删除node_modules 】

3)$ yarn config set registry https://registry.yarnpkg.com 【安装yarn镜像】

4)$ yarn upgrade v1.17.3 --no-bin-links 【用这个方法升级yarn】

5)$ yarn add cross-env --no-bin-links 【用这个方法成功保存了1个新的依赖】

6)resources/sass/app.scss 文件内,只保留
// Bootstrap
@import '~bootstrap/scss/bootstrap';

7)$ npm run dev --no-bin-links 【执行成功】

8)$ npm run watch-poll 【执行成功!】

为进一步确定是否执行成功,我退出虚拟机,关闭电脑,重新开机启动虚拟机,再执行npm run watch-poll
再次看到这一幕:) 希望对出现同样问题的同学有帮助。
file

4年前 评论
bing_ (作者) (楼主) 4年前
c_san 4年前
c_san 4年前

当我切回到 Git 的主分支上。 $ git checkout master 没有发现新增了一个 public/css 文件夹 我再运行 npm run watch-poll 就又报错了 :( 看来这个方法不能彻底解决问题 $ yarn add cross-env --no-bin-links
file
Laravel

还是报同一个错误,what should I do?

4年前 评论

现在,我又用老办法重新执行成功:
https://blog.csdn.net/weixin_42221416/arti...
回到主分支,没有发现新增一个 public/css 文件夹我也没办法,不影响页面显示效果姑且用之。

我执行以下命令报错
npm run dev
换下面命令执行成功
npm run dev --no-bin-links
npm run watch-poll

4年前 评论

记得将文章里面的devdependencies里面的配置项
复制粘贴到自己项目里面的 package.json文件 对应的devDependencies下面, 在 yarn install --no-bin-links

4年前 评论
bing_ (楼主) 4年前

你切换主分支之后,所有的代码都没了(没有合并分支),因为你是在其他分支上写的,应该是需要合并分支,才能把其他分支的代码修改合并到主分支上吧

4年前 评论
bing_ (楼主) 4年前

嗯,本来我去年写的shop项目也没有问题,一直处于正常状态,直到我上次再次修改时,发现css样式有点问题。顺手调试了一下,结果就出现了跟楼主一模一样的问题。经过我两个多小时的查找最后终于发现了问题的所在。 1.确保安装了npm 2.确保安装了node 3.确保安装了node-sass 最后也是以为是版本不一样导致的,经过从新逐个安装尝试以后发现是缺少了yarn ; 首先切换国内淘宝源: yarn config set registry registry.npm.taobao.org 查看是否安装成功:yar n --version 运行:npm run watch-poll

file

最后成功

总结:刚开始也是看这个那个文件 什么mix.js之类的,一直就是编译js、css文件后,总是没有编译css文件导致的。 希望能帮助到后来的踩坑人,如果对你有帮助,请

3年前 评论

我通过执行以下操作解决了此事件: npm install --save-dev sass-loader npm install --save-dev sass-loader@7.1.0

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!