Hello,
I am very new to Node so I might be doing something wrong...
I'm on Win 7 x64 and I ran the following successfully:
nvm use 4
npm install
However when I attempt to run:
npm run build or npm run build_windows
I get the following error:
c:\Users\seccial\node source\nlp_compromise-master>npm run build
> [email protected] build c:\Users\seccial\node source\nlp_compromise-master
> grunt build
Running "run:test" (run) task
'.' is not recognized as an internal or external command,
operable program or batch file.
Warning: non-zero exit code 255 Use --force to continue.
Aborted due to warnings.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `grunt build`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the [email protected] build script 'grunt build'.
npm ERR! This is most likely a problem with the nlp_compromise package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! grunt build
npm ERR! You can get their info via:
npm ERR! npm owner ls nlp_compromise
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\Users\seccial\node source\nlp_compromise-master\npm-debug.log
and
c:\Users\seccial\node source\nlp_compromise-master>npm run build_windows
> [email protected] build_windows c:\Users\seccial\node source\nlp_compromise
-master
> grunt build_windows
Warning: Task "build_windows" not found. Use --force to continue.
Aborted due to warnings.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "run" "build_windows"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build_windows: `grunt build_windows`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the [email protected] build_windows script 'grunt build_wi
ndows'.
npm ERR! This is most likely a problem with the nlp_compromise package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! grunt build_windows
npm ERR! You can get their info via:
npm ERR! npm owner ls nlp_compromise
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\Users\seccial\node source\nlp_compromise-master\npm-debug.log
Can anyone build on Windows? The grunt file does not look like it caters for Windows ie.
run: {
cleanup: { //remove builds
exec: 'rm -rf ./builds && mkdir builds'
},
init: { //add a header, before browserify
exec: 'echo "/* nlp_compromise v<%= pkg.version %> MIT*/" > ' + uncompressed
},
build: { //browserify -> babel -> derequire
exec: browserify + ' ./src/index.js --standalone nlp_compromise -t [ babelify --presets [ es2015 ] ] | derequire >> ' + uncompressed
},
uglify: { // jsFile -> jsFile.min
exec: uglify + ' ' + uncompressed + ' --mangle --compress --output ' + compressed + ' --preamble "/*nlp_compromise v<%= pkg.version %> MIT*/"' // --source-map ' + compressed + '.map'
},
test: {
exec: tape + ' ./test/unit_test/**/*_test.js | ' + tapSpec
},
browser_test: {
exec: 'browserify ./test/unit_test/*_test.js -o ./test/browser_test/compiled_tests.js && ' + fileServer + ' test/browser_test -o -c-1'
},
prerelease: { //test all versions serverside, client-side
exec: tape + ' ./test/prerelease/index.js | ' + tapSpec
},
demo: {
exec: fileServer + ' demo -o -c-1'
},
main: {
exec: 'node ./src/index.js'
},
build_windows: {
},
demo_windows: {
}
},
Thanks in advance,
Leo
I can build and run fine on Ubuntu...
hey Leonardo! thanks. Yeah, it's really as simple as using \ vs / i beleive. I may have inadvertently removed the build_windows script. Sorry for the problems it's caused. In the newest version i've addressed this by using shelljs, which I think handles all of that. Here's the command, i think, which will make a build on windows:
.\node_modules\.bin\browserify .\src\index.js --standalone nlp_compromise -t [ babelify --presets [ es2015 ] ] | derequire >> .\builds\nlp_compromise.js
i haven't tested that, but should be close,
cheers
that doesn't look right, does it.
anyways, it's
browserify + input file + babel transform + into derequire + write to outfile
ewww, WELCOME TO NODEJS! 馃槄
Thank you... I'll look into it. I like your v7 branch improvements, I am going to try it out.
Thanks again,
Leo
I have a small Gulp Script I use to run the build on Windows to work around the browserify issues.
If it's useful, let me know and I can polish it up and commit it.
I thought this was resolved in v7 but actually built js file is empty... I'm going to look into it.
you ran npm run build and ./builds/compromise.js is empty?
yikes.
yeah it's using a library called shelljs now, which i think should work with windows
yes - the errors start appearing again when I change async to false in the exec commands...
I think the issue is mainly due to paths slashes being inverted in Windows - not completely sure. I looked into it for a while, I messed up my nodejs installation and then decided to just use my Linux VM instead.
I will give it some more time soon.
Leo
Hello,
Here is my build.js for Windows:
require('shelljs/global');
config.silent = true;
var fs = require('fs');
//use paths, so libs don't need a -g
var browserify = '.\\node_modules\\.bin\\browserify';
var derequire = '.\\node_modules\\.bin\\derequire';
var uglify = '.\\node_modules\\.bin\\uglifyjs';
var eslint = '.\\node_modules\\.bin\\eslint';
var pkg = JSON.parse(fs.readFileSync('.\\package.json', 'utf8'));
//first, run linter
var child = exec(eslint + ' -c .eslintrc --color .\\src\\**');
//final build locations
var banner = '/* compromise v' + pkg.version + '\n github.com/nlp-compromise\n MIT\n*/\n';
var uncompressed = '.\\builds\\compromise.js';
var compressed = '.\\builds\\compromise.min.js';
//cleanup. remove old builds
exec('rmdir /S /Q .\\builds && mkdir builds');
//add a header, before our sourcecode
echo(banner).to(uncompressed);
echo(banner).to(compressed);
//browserify + derequire
var cmd = browserify + ' .\\src\\index.js --standalone nlp';
cmd += ' -t [ babelify --presets [ es2015 stage-2 ] ]';
cmd += ' | ' + derequire;
cmd += ' >> ' + uncompressed;
//console.log(cmd);
exec(cmd);
//uglify
cmd = uglify + ' ' + uncompressed + ' --mangle --compress ';
cmd += ' >> ' + compressed;
//console.log(cmd);
exec(cmd); // --source-map ' + compressed + '.map'
//print filesizes
var stats = fs.statSync(compressed);
var fileSize = (stats['size'] / 1000.0).toFixed(2);
console.log('\n\n' + fileSize + 'kb');
It all works now...
I won't close the issue as you might want it open as a reminder to include this in main v7 branch.
Leo
Most helpful comment
I have a small Gulp Script I use to run the build on Windows to work around the browserify issues.
If it's useful, let me know and I can polish it up and commit it.