加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

将node-sass与docker-compose一起使用

发布时间:2020-12-16 03:50:09 所属栏目:安全 来源:网络整理
导读:我目前正在使用docker执行我的第一步,并尝试使用docker-compose来运行我的应用程序: Node-Backend:hapi JS-Frontend:棱角分明 MongoDB数据库 mongodb与docker结合使用.我正在开发OSX机器并使用node-sass作为前端部分.作曲时有一个错误: server_1 | Child

我目前正在使用docker执行我的第一步,并尝试使用docker-compose来运行我的应用程序:

Node-Backend:hapi
JS-Frontend:棱角分明
MongoDB数据库

mongodb与docker结合使用.我正在开发OSX机器并使用node-sass作为前端部分.作曲时有一个错误:

server_1  |     Child extract-text-webpack-plugin:
server_1  |       + 1 hidden modules
server_1  |     
server_1  |     ERROR in Missing binding /app/node_modules/node-sass/vendor/linux-x64-48/binding.node
server_1  |     Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 6.x
server_1  |     
server_1  |     Found bindings for the following environments:
server_1  |       - OS X 64-bit with Node.js 6.x
server_1  |     
server_1  |     This usually happens because your environment has changed since running `npm install`.
server_1  |     Run `npm rebuild node-sass` to build the binding for your current environment.

node-sass模块似乎需要linux绑定,但只是在容器内部有osx绑定.所以问题是:有没有一种聪明的方法来解决这个问题,即使开发过程仍然很舒服?

到目前为止,我没有任何Dockerfile.但我的docker-compose.yml看起来像:

version: '2'
services:
  server:
    image: node:6
    command: 'npm start'
    working_dir: '/app'
    volumes:
      - ./:/app
    depends_on:
      - mongo
    ports:
      - '1337:1337'
    environment:
      - NODE_ENV=prod
    links:
      - mongo:mongodb
  mongo:
    image: mongo:latest
    ports:
      - '127.0.0.1:27017:27017'
    volumes:
      - ./data/:/data/db

而package.json:

...

  "dependencies": {
    "accepts": "^1.3.3","akaya": "^0.3.0","angular": "^1.5.8","angular-ui-router": "next","bcrypt": "^0.8.7","blipp": "^2.3.0","boom": "^4.2.0","emojilib": "^2.0.2","emojione": "^2.2.6","glue": "^4.0.0","good": "^7.0.2","good-console": "^6.1.2","good-file": "^6.0.1","good-squeeze": "^5.0.0","hapi": "^15.2.0","hapi-auth-basic": "^4.2.0","hapi-auth-jwt2": "^7.1.3","inert": "^4.0.2","joi": "^9.2.0","jquery": "^3.1.1","jsonwebtoken": "^7.1.9","lodash": "^4.16.4","mongoose": "^4.6.4","pm2": "^2.0.18","twemoji": "^2.2.0","wurst": "^0.9.1"
  },"devDependencies": {
    "autoprefixer": "^6.5.1","babel-cli": "^6.16.0","babel-core": "^6.17.0","babel-eslint": "^7.0.0","babel-loader": "^6.2.5","babel-plugin-transform-decorators-legacy": "^1.3.4","babel-preset-es2015": "^6.16.0","babel-preset-stage-0": "^6.16.0","baggage-loader": "^0.2.4","chokidar": "^1.6.1","clean-webpack-plugin": "^0.1.13","copy-webpack-plugin": "^3.0.1","css-loader": "^0.25.0","eslint": "^3.8.1","eslint-config-airbnb-base": "^9.0.0","eslint-loader": "^1.6.0","eslint-plugin-import": "^2.0.1","extract-text-webpack-plugin": "^1.0.1","file-loader": "^0.9.0","html-loader": "^0.4.4","html-webpack-plugin": "^2.24.0","inline-style-prefix-all": "^2.0.2","json-loader": "^0.5.4","ng-annotate-loader": "^0.2.0","ngtemplate-loader": "^1.3.1","node-sass": "^3.10.1","postcss-loader": "^1.0.0","sass-loader": "^4.0.2","style-loader": "^0.13.1","url-loader": "^0.5.7","webpack": "^1.13.2","webpack-livereload-plugin": "^0.9.0","webpack-manifest-plugin": "^1.1.0","webpack-md5-hash": "^0.0.5"
  },"engines": {
    "node": "6.0.0","npm": "^3.8.8"
  }

谢谢!!

编辑:我的本地目录./被挂载到容器,所以我的OSX绑定模块也被挂载.是否有一种聪明的方法可以在容器内部执行新的npm i,而不会对开发过程有任何更大的限制?

最佳答案
您需要在容器内运行npm rebuild node-sass.您正在安装为OSX编译的二进制文件并尝试在Linux上运行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读