webpack / vue-cli / sass 出错:“无法从共享对象映射段:不允许操作”
Posted
技术标签:
【中文标题】webpack / vue-cli / sass 出错:“无法从共享对象映射段:不允许操作”【英文标题】:Error with webpack / vue-cli / sass: "failed to map segment from shared object: Operation not permitted" 【发布时间】:2017-12-18 01:54:00 【问题描述】:当我尝试使用 webpack 命令“npm run dev”启动服务器时出现以下错误:
ERROR in ./~/css-loader!./~/vue-loader/lib/style-compiler?"vue":true,"id":"data-v-9ff273a2","scoped":false,"hasInlineConfig":false!./~/sass-loader/lib/loader.js!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue
Module build failed: Error: /var/www/html/my_project_name/node_modules/node-sass/vendor/linux-x64-48/binding.node: failed to map segment from shared object: Operation not permitted
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
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 module.exports (/var/www/html/my_project_name/node_modules/node-sass/lib/binding.js:19:10)
at Object.<anonymous> (/var/www/html/my_project_name/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:570:32)
@ ./~/vue-style-loader!./~/css-loader!./~/vue-loader/lib/style-compiler?"vue":true,"id":"data-v-9ff273a2","scoped":false,"hasInlineConfig":false!./~/sass-loader/lib/loader.js!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-317 13:3-17:5 14:22-325
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/main.js
我的环境:
Centos7 通过 VirtualBox(安装在 Windows7 上)和一个挂载的文件夹 节点版本:6.10.3 Npm 版本:3.10.10 我支持公司代理我做了什么:
我安装了 vue-cli:
sudo npm install -g vue-cli --no-bin-links
我使用“使用 sass”选项创建了一个新的 vue-cli 项目:
vue init webpack-simple my_project_name
我安装了依赖项:
cd my_project_name
sudo npm install --no-bin-links
在“package.json”文件中,我替换了:
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot"
与:
"dev": "cross-env NODE_ENV=development webpack-dev-server --hot --port 8080 --host 0.0.0.0"
在“node_modules/webpack-dev-server/lib/Server.js”文件中,我添加了:
options.watchOptions =
aggregateTimeout: 300,
poll: true
;
我卸载了 sass,然后又重新安装了 sass:
npm uninstall node-sass --save-dev
sudo npm install node-sass --save-dev --no-bin-links
现在,我尝试启动服务器:
npm run dev
我收到以下错误:
ERROR in ./~/css-loader!./~/vue-loader/lib/style-compiler?"vue":true,"id":"data-v-9ff273a2","scoped":false,"hasInlineConfig":false!./~/sass-loader/lib/loader.js!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue
Module build failed: Error: /var/www/html/my_project_name/node_modules/node-sass/vendor/linux-x64-48/binding.node: failed to map segment from shared object: Operation not permitted
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
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 module.exports (/var/www/html/my_project_name/node_modules/node-sass/lib/binding.js:19:10)
at Object.<anonymous> (/var/www/html/my_project_name/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (module.js:570:32)
@ ./~/vue-style-loader!./~/css-loader!./~/vue-loader/lib/style-compiler?"vue":true,"id":"data-v-9ff273a2","scoped":false,"hasInlineConfig":false!./~/sass-loader/lib/loader.js!./~/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-317 13:3-17:5 14:22-325
@ ./src/App.vue
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://0.0.0.0:8080 webpack/hot/dev-server ./src/main.js
关于信息,如果我在使用“vue init”创建项目时不激活“sass”选项,一切正常。
请问有人知道怎么解决吗?
【问题讨论】:
【参考方案1】:我找到了解决办法。
在我的“/etc/fstab”文件中,我使用以下参数安装了我的文件夹:
users,rw,credentials=/root/.creds,file_mode=0777,dir_mode=0777,uid=1000,gid=100 0 0
我更改了这些参数,如下所示:
rw,credentials=/root/.creds,file_mode=0777,dir_mode=0777,uid=1000,gid=100,exec 0 0
现在一切正常!
【讨论】:
以上是关于webpack / vue-cli / sass 出错:“无法从共享对象映射段:不允许操作”的主要内容,如果未能解决你的问题,请参考以下文章
带有 SASS 的 Webpack-simple + vue-cli - 无法编译?
vuejs:vue-cli webpack 模板无法解析 sass 导入
vuejs:vue-cli webpack模板无法解析sass导入
webpack 配置scssless全局样式(自定义的,vue-cli2/3)