Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: Postinstall Failed on Windows 10 #376

Comments

@arnydo
Copy link
Contributor

arnydo commented Oct 4, 2018

Summary

When running "npm install" on Windows 10 the following error is generated:

'[' is not recognized as an internal or external command,
operable program or batch file.

Example

  1. Install Git
    
  2. Install Node.js and its package manager, npm
    
  3. Install Grunt: npm install -g grunt-cli
    
  4. git clone https://github.com/gchq/CyberChef.git
    
  5. cd CyberChef
    
  6. npm install
    

Error:

npm install

> cyberchef@8.7.0 postinstall C:\CyberChef
> [ -f node_modules/crypto-api/src/crypto-api.mjs ] || npx j2m node_modules/crypto-api/src/crypto-api.js

'[' is not recognized as an internal or external command,
operable program or batch file.
Failed to parse: C:\CyberChef\node_modules\crypto-api\src\crypto-api.js
{ Error: ENOENT: no such file or directory, open 'C:\CyberChef\node_modules\crypto-api\src\crypto-api.js'
    at Object.openSync (fs.js:436:3)
    at readFileSync (fs.js:341:35)
    at parseImports (C:\CyberChef\node_modules\js-to-mjs\src\find.js:36:16)
    at main (C:\CyberChef\node_modules\js-to-mjs\index.js:18:25)
    at Object.<anonymous> (C:\CyberChef\node_modules\js-to-mjs\index.js:61:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path:
   'C:\CyberChef\\node_modules\\crypto-api\\src\\crypto-api.js' }
ENOENT: no such file or directory, rename 'C:\CyberChef\node_modules\crypto-api\src\crypto-api.js' -> 'C:\CyberChef\node_modules\crypto-api\src\crypto-api.mjs'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! cyberchef@8.7.0 postinstall: `[ -f node_modules/crypto-api/src/crypto-api.mjs ] || npx j2m node_modules/crypto-api/src/crypto-api.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cyberchef@8.7.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\me\AppData\Roaming\npm-cache\_logs\2018-10-04T20_58_38_712Z-debug.log
@iwiwsb
Copy link

iwiwsb commented Oct 6, 2018

I guess it's because

"postinstall": "[ -f node_modules/crypto-api/src/crypto-api.mjs ] || npx j2m node_modules/crypto-api/src/crypto-api.js"

is a Bash command. So you can build CyberChef only on Linux and MacOS.

Maybe there is a way to create a cross-platform package.json, but I don't know how.

@arnydo
Copy link
Contributor Author

arnydo commented Oct 17, 2018

Ended up using Docker and Gitlab CI to build...

@arnydo arnydo closed this as completed Oct 17, 2018
@david-robson
Copy link

On Windows 10, as of build 14328, there is the possibility to install a Bash shell, which worked fine for me.

Note that after the "npm install", I also had to run "npm update" before the build (grunt dev) would run.

For the node.js version to run (grunt node), I updated Gruntfile.js and commented out the 2 lines with "whitelist: ["crypto-api/src/crypto-api"]". This was to fix the following error:

CyberChef/node_modules/crypto-api/src/crypto-api.mjs:3
import Has160 from "./hasher/has160";
       ^^^^^^
SyntaxError: Unexpected identifier

Gruntfile.js lines 204 - 242:

            node: {
                mode: NODE_PROD ? "production" : "development",
                target: "node",
                entry: "./src/node/index.mjs",
//                externals: [NodeExternals({
//                    whitelist: ["crypto-api/src/crypto-api"]
//                })],
                output: {
                    filename: "CyberChef.js",
                    path: __dirname + "/build/node",
                    library: "CyberChef",
                    libraryTarget: "commonjs2"
                },
                plugins: [
                    new webpack.DefinePlugin(BUILD_CONSTANTS),
                    new webpack.optimize.LimitChunkCountPlugin({
                        maxChunks: 1
                    })
                ],
            },
            nodeRepl: {
                mode: NODE_PROD ? "production" : "development",
                target: "node",
                entry: "./src/node/repl-index.mjs",
//                externals: [NodeExternals({
//                    whitelist: ["crypto-api/src/crypto-api"]
//                })],
                output: {
                    filename: "CyberChef-repl.js",
                    path: __dirname + "/build/node",
                    library: "CyberChef",
                    libraryTarget: "commonjs2"
                },
                plugins: [
                    new webpack.DefinePlugin(BUILD_CONSTANTS),
                    new webpack.optimize.LimitChunkCountPlugin({
                        maxChunks: 1
                    })
                ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment