版本
c:\dev\sam>npm -v
5.5.1
c:\dev\sam>node -v
v8.9.2
c:\dev\sam>
问题
c:\dev\sam> mvnw -Pprod -DskipTests package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SAM 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- frontend-maven-plugin:1.4:install-node-and-npm (install node and npm) @ sam ---
[INFO] Node v6.11.0 is already installed.
[INFO] NPM 5.0.3 is already installed.
...
INFO] ERROR in ./node_modules/css-loader!./node_modules/postcss-loader/lib!./node_modules/sass-loader/lib/loader.js!./src/main/webapp/content/scss/global.scss
[INFO] Module build failed: Error: Missing binding c:\dev\sam\node_modules\node-sass\vendor\win32-x64-48\binding.node
[INFO] Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 6.x
[INFO]
[INFO] Found bindings for the following environments:
[INFO] - Windows 64-bit with Node.js 8.x
[INFO]
[INFO] This usually happens because your environment has changed since running `npm install`.
[INFO] Run `npm rebuild node-sass` to download the binding for your current environment.
...
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.684 s
[INFO] Finished at: 2018-07-12T06:56:14+01:00
[INFO] Final Memory: 35M/501M
[INFO] ------------------------------------------------------------------------
package.json
c:\dev\sam>more package.json
{
"name": "sam",
"version": "0.0.0",
"description": "Description for SAM",
"private": true,
"cacheDirectories": [
"node_modules"
],
"dependencies": {
"@angular/animations": "5.2.10",
"@angular/cdk": "5.2.5",
"@angular/common": "5.2.0",
"@angular/compiler": "5.2.0",
"@angular/core": "5.2.0",
"@angular/forms": "5.2.0",
"@angular/http": "5.2.0",
"@angular/material": "5.2.5",
"@angular/platform-browser": "5.2.0",
"@angular/platform-browser-dynamic": "5.2.0",
"@angular/router": "5.2.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0",
"angular-calendar": "^0.25.1",
"angular-highcharts": "6.0.0",
"bootstrap": "4.0.0",
"core-js": "2.4.1",
"font-awesome": "4.7.0",
"highcharts": "6.1.0",
"jquery": "3.2.1",
"lodash": "4.17.5",
"ng-jhipster": "0.4.0",
"ng2-nouislider": "1.7.7",
"ng2-pdf-viewer": "4.1.2",
"ngx-cookie": "2.0.1",
"ngx-infinite-scroll": "0.5.1",
"ngx-stripe": "0.8.2",
"ngx-webstorage": "2.0.1",
"nouislider": "11.1.0",
"reflect-metadata": "0.1.10",
"rxjs": "5.5.6",
"sockjs-client": "1.1.4",
"swagger-ui": "2.2.10",
"tether": "1.4.0",
"webstomp-client": "1.0.6",
"zone.js": "0.8.19",
"popper.js": "^1.12.9"
},
"devDependencies": {
"@angular/cli": "1.6.6",
"@angular/compiler-cli": "5.2.0",
"@ngtools/webpack": "1.8.5",
"@types/highcharts": "5.0.22",
"@types/jasmine": "2.5.53",
"@types/lodash": "4.14.107",
"@types/node": "8.0.18",
"angular2-template-loader": "0.6.2",
"awesome-typescript-loader": "3.2.2",
"browser-sync": "2.18.13",
"browser-sync-webpack-plugin": "1.2.0",
"codelyzer": "4.0.1",
"copy-webpack-plugin": "4.2.3",
"css-loader": "0.28.4",
"exports-loader": "0.6.4",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"generator-jhipster": "4.14.3",
"html-loader": "0.5.0",
"html-webpack-plugin": "2.30.1",
"jasmine-core": "2.7.0",
"karma": "1.7.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.1",
"karma-intl-shim": "1.0.3",
"karma-jasmine": "1.1.0",
"karma-junit-reporter": "1.2.0",
"karma-notify-reporter": "1.0.1",
"karma-phantomjs-launcher": "1.0.4",
"karma-remap-istanbul": "0.6.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.4",
"node-sass": "^4.9.2",
"phantomjs-prebuilt": "2.1.16",
"postcss-loader": "2.0.9",
"proxy-middleware": "0.15.0",
"rimraf": "2.6.1",
"sass-loader": "6.0.6",
"source-map": "0.6.1",
"sourcemap-istanbul-instrumenter-loader": "0.2.0",
"style-loader": "0.18.2",
"to-string-loader": "1.1.5",
"tslint": "5.5.0",
"tslint-loader": "3.5.3",
"typescript": "2.6.2",
"uglifyjs-webpack-plugin": "1.1.5",
"web-app-manifest-loader": "0.1.1",
"webpack": "3.10.0",
"webpack-dev-server": "2.9.5",
"webpack-merge": "4.1.1",
"webpack-notifier": "1.5.1",
"webpack-visualizer-plugin": "0.1.11",
"workbox-webpack-plugin": "3.0.0-beta.1",
"write-file-webpack-plugin": "4.1.0",
"xml2js": "0.4.17"
},
"engines": {
"node": ">=6.9.0"
},
"resolutions": {
"source-map": "0.6.1"
},
"scripts": {
"lint": "tslint --project tsconfig.json -e 'node_modules/**'",
"lint:fix": "npm run lint -- --fix",
"ngc": "ngc -p tsconfig-aot.json",
"cleanup": "rimraf target/{aot,www}",
"clean-www": "rimraf target//www/app/{src,target/}",
"start": "npm run webpack:dev",
"serve": "npm run start",
"build": "npm run webpack:prod",
"test": "npm run lint && karma start src/test/javascript/karma.conf.js",
"test:watch": "npm test -- --watch",
"webpack:dev": "npm run webpack-dev-server -- --config webpack/webpack.dev.js --progress --inline --hot --profile --port=9060 --watch-content-base",
"webpack:build:main": "npm run webpack -- --config webpack/webpack.dev.js --progress --profile",
"webpack:build": "npm run cleanup && npm run webpack:build:main",
"webpack:prod:main": "npm run webpack -- --config webpack/webpack.prod.js --profile",
"webpack:prod": "npm run cleanup && npm run webpack:prod:main && npm run clean-www",
"webpack:test": "npm run test",
"webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js",
"webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js",
"postinstall": "node node_modules/phantomjs-prebuilt/install.js"
}
}
问题
我不确定为什么会失败。
开发版本运行正常。
产品构建失败(从未成功)。
由于某种原因,npm正在寻找不同版本的nodejs(6),而不是我已经安装的版本(8),也许是吗?
我确实有一个绑定文件,但没有构建所需的文件。
我已经清理了我的node_modules并再次安装,但是并没有解决问题。
我已经尝试过npm rebuild node-sass了,但是也许这是下载那里的版本(8)而不是(6)吗?
我应该“降级”到6吗? 或如何升级内部版本?
有人建议如何解决这个问题,原因是什么?
正确的配置应该是什么?
注意:这是一个jhipster生成的项目(如果有任何区别)。
感谢您花100万时间解释这一点。
亲切的问候, Fergal。
答案 0 :(得分:1)
Prod版本不使用您在PC上安装的节点版本,而是在pom.xml中指定的node子文件夹下本地安装一个版本。因此,您可以尝试编辑pom.xml,并使用与PC相同版本的node和npm。