webpack 使用正确的节点版本

webpack use correct node version

在我的节点项目中,我有一个类似于

的生成文件
SHELL:=/bin/bash --login

PROJECT_NAME = Webapp
PROJECT_URL = https://github.com/nkhine/myapp

# Name variables
BUILD_ASSETS = $(wildcard ./build/*.*)
dev: node_modules
    GIT_DESCRIBE=`git describe --long --tags --dirty --always` \
    nvm exec node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js

在我的开发机器上我已经安装了 nvm 并且一切似乎都正常工作

$ node --version
v4.2.4

但是当我运行

$ make dev
    GIT_DESCRIBE=`git describe --long --tags --dirty --always` \
    nvm exec node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js
Running node v6.2.0 (npm v3.8.9)

然后我得到

  [975] ./~/style-loader/addStyles.js 7.15 kB {1} [built]
     + 3 hidden modules

ERROR in Missing binding /home/khine/Sandboxes/webapp/node_modules/node-sass/vendor/linux-x64-48/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 6.x

Found bindings for the following environments:
  - Linux 64-bit with Node.js 4.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
 @ ./~/styleguide/src/styles/styles.scss 4:14-715 13:2-17:4 14:20-721

如何强制webpack使用node的nvm版本?

运行 node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js 工作正常

nvm use v4.2.4,赞

nvm use v4.2.4 && \
node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack.dev.config.js