Ben*_*Ben 0 node.js docker node-sass webpack-dev-server webpack-style-loader
我正在努力根据以下内容在docker容器中获取webpack开发服务器设置 node:latest
尽管尝试了Node Sass中的所有各种错误,都无法找到适合您当前环境的绑定,但我仍然遇到相同的错误:
web_1 | ERROR in ./~/css-loader!./~/sass-loader/lib/loader.js!./src/sass/style.sass
web_1 | Module build failed: Error: Missing binding /prject/node_modules/node-sass/vendor/linux-x64-59/binding.node
web_1 | Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 9.x
web
Run Code Online (Sandbox Code Playgroud)
这是当前
# Dockerfile
RUN yarn cache clean && yarn install --non-interactive --force
RUN rm -rf node_modules/node_sass
RUN npm rebuild node-sass
Run Code Online (Sandbox Code Playgroud)
重建步骤表明已安装二进制文件并签出:
Binary found at /advocate/node_modules/node-sass/vendor/linux-x64-59/binding.node
Testing binary
Binary is fine
Run Code Online (Sandbox Code Playgroud)
我也感到困惑的是
web_1 | Found bindings for the following environments:
web_1 | - OS X 64-bit with Node.js 7.x
Run Code Online (Sandbox Code Playgroud)
这让我觉得它正在以某种我不太了解的能力使用主机平台。
node_modules目录的状态从开发主机进入容器中。当在npm/yarn install使用本机代码的通常是模块的过程中做出基于平台的决策时,这是一个问题。
添加node_modules到您的.dockerignore文件。安装将在容器中花费更长的时间,但是您永远不应在开发环境和容器之间发生任何交叉。
将开发代码安装node_modules到容器中也会引起同样的问题。yarn install --force在使用新平台之前,在新平台上运行它通常应该足以切换它。
挂载卷时,没有简单的方法可以忽略目录。您可以分别挂载项目中的每个目录/文件,然后忽略node_modules它,但这是很多工作。
这是避免安装卷的方法。docker-sync具有可以忽略文件的rsync策略。这也可能会加快某些具有大量文件访问模式的应用程序的速度。从osx> vm> docker挂载的卷上的文件访问速度很慢。
version: '2'
options:
verbose: true
syncs:
yourproject_data:
sync_strategy: 'rsync'
src: './'
sync_host_port: 10872
sync_args: '-v'
sync_excludes:
- '.sass-cache/'
- 'sass-cache/'
- 'vendor/'
- 'bower_components/'
- 'node_modules/'
- '.git/'
Run Code Online (Sandbox Code Playgroud)
默认情况下,文件删除不会同步到容器,您需要考虑这一点。当我需要清理时,偶尔删除同步卷。
| 归档时间: |
|
| 查看次数: |
1252 次 |
| 最近记录: |