node-sass vagrant box 安装问题

node-sass install issue with vagrant box

我正在尝试 运行 npm install 进入我的 vag运行t 盒子,但出现此错误:

node-sass@4.1.1 install /vagrant/MyStrainGuide/client/node_modules/node-sass
> node scripts/install.js

/vagrant/MyStrainGuide/client/node_modules/boom/lib/index.js:146
        for (i = 0, il = wwwArray.length; i < il; ++

SyntaxError: Invalid or unexpected token
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/vagrant/MyStrainGuide/client/node_modules/hawk/lib/index.js:3:33)
    at Module._compile (module.js:571:32)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN react-markdown-area@0.3.8 requires a peer of react@^0.14.5 but none was installed.
npm WARN react-markdown-area@0.3.8 requires a peer of react-dom@^0.14.5 but none was installed.
npm WARN react-webpack-rails-tutorial@0.0.1 No description
npm WARN react-webpack-rails-tutorial@0.0.1 No repository field.
npm WARN react-webpack-rails-tutorial@0.0.1 No license field.
npm WARN ETXTBSY: text file is busy, rmdir '/vagrant/MyStrainGuide/client/node_modules/dashdash/node_modules'
npm ERR! Linux 3.13.0-105-generic
npm ERR! argv "/home/vagrant/.nvm/versions/node/v7.4.0/bin/node" "/home/vagrant/.nvm/versions/node/v7.4.0/bin/npm" "install"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE

npm ERR! node-sass@4.1.1 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.1.1 install script 'node scripts/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-sass package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-sass
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-sass
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /vagrant/MyStrainGuide/client/npm-debug.log

我运行以管理员身份管理虚拟框,因此不应该有符号链接问题。

根据我的 google 搜索,我 运行 npm rebuild node-sass 但仍未解决。

我当前的节点版本是:v7.4.0

npm 版本为:4.0.5

我运行正在装这个盒子https://github.com/fideloper/Vaprobash

======

附带说明一下,我仍然尝试使用 foreman start -f Procfile.dev

运行 服务器

这是输出:

02:35:31 client.1 | > webpack -w --config webpack.config.js --watch-poll
02:35:31 client.1 |
02:35:32 client.1 | /vagrant/MyStrainGuide/client/node_modules/enhanced-resolve/lib/node.js:60
02:35:32 client.1 | module.exports.sync = function resolveSync(context,
02:35:32 client.1 |
02:35:32 client.1 | SyntaxError: Invalid or unexpected token
02:35:32 client.1 |     at Object.exports.runInThisContext (vm.js:78:16)
02:35:32 client.1 |     at Module._compile (module.js:543:28)
02:35:32 client.1 |     at Object.Module._extensions..js (module.js:580:10)
02:35:32 client.1 |     at Module.load (module.js:488:32)
02:35:32 client.1 |     at tryModuleLoad (module.js:447:12)
02:35:32 client.1 |     at Function.Module._load (module.js:439:3)
02:35:32 client.1 |     at Module.require (module.js:498:17)
02:35:32 client.1 |     at require (internal/module.js:20:19)
02:35:32 client.1 |     at Object.<anonymous> (/vagrant/MyStrainGuide/client/node_modules/webpack/bin/convert-argv.js:4:15)
02:35:32 client.1 |     at Module._compile (module.js:571:32)
02:35:32 client.1 |
02:35:32 client.1 | npm ERR! Linux 3.13.0-105-generic
02:35:32 client.1 | npm ERR! argv "/home/vagrant/.nvm/versions/node/v7.4.0/bin/node" "/home/vagrant/.nvm/versions/node/v7.4.0/bin/npm" "run" "build:development"
02:35:32 client.1 | npm ERR! node v7.4.0
02:35:32 client.1 | npm ERR! npm  v4.0.5
02:35:32 client.1 | npm ERR! code ELIFECYCLE
02:35:32 client.1 | npm ERR! react-webpack-rails-tutorial@0.0.1 build:development: `webpack -w --config webpack.config.js --watch-poll`
02:35:32 client.1 | npm ERR! Exit status 1
02:35:32 client.1 | npm ERR!
02:35:32 client.1 | npm ERR! Failed at the react-webpack-rails-tutorial@0.0.1 build:development script 'webpack -w --config webpack.config.js --watch-poll'.
02:35:32 client.1 | npm ERR! Make sure you have the latest version of node.js and npm installed.
02:35:32 client.1 | npm ERR! If you do, this is most likely a problem with the react-webpack-rails-tutorial package,
02:35:32 client.1 | npm ERR! not with npm itself.
02:35:32 client.1 | npm ERR! Tell the author that this fails on your system:
02:35:32 client.1 | npm ERR!     webpack -w --config webpack.config.js --watch-poll
02:35:32 client.1 | npm ERR! You can get information on how to open an issue for this project with:
02:35:32 client.1 | npm ERR!     npm bugs react-webpack-rails-tutorial
02:35:32 client.1 | npm ERR! Or if that isn't available, you can get their info via:
02:35:32 client.1 | npm ERR!     npm owner ls react-webpack-rails-tutorial
02:35:32 client.1 | npm ERR! There is likely additional logging output above.
02:35:32 client.1 |
02:35:32 client.1 | npm ERR! Please include the following file with any support request:
02:35:32 client.1 | npm ERR!     /vagrant/MyStrainGuide/client/npm-debug.log
02:35:33 client.1 | exited with code 1
02:35:33 system   | sending SIGTERM to all processes
02:35:33 web.1    | terminated by SIGTERM

我假设这是因为 npm install 没有正确完成。我以前从未遇到过这个问题。这是我设置的全新盒子。

我也为这个确切的问题苦苦挣扎了很长一段时间。我能够根据此处的建议解决它 - https://github.com/mitchellh/vagrant/issues/7163

向下滚动到倒数第二条评论,然后按照这些步骤将您的 node_modules 文件夹移出共享文件夹,这应该会为您解决所有问题。

为了方便,这里是评论

There are some issues with installing the node packages directly in the shared folder. A good workaround is to install the packages somewhere inside the vm then create a symlink.
Ex:
cd /vagrant
rm -rf node_modules
mkdir /home/vagrant/vagrant_node_modules
cp package.json /home/vagrant/vagrant_node_modules
cd /home/vagrant/vagrant_node_modules
npm install
cd /vagrant
ln -s /home/vagrant/vagrant_node_modules/node_modules node_modules
ls -ld node_modules