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

Support creating ajv bundle in Windows #206

Closed
sushant160185 opened this issue Jun 7, 2016 · 26 comments
Closed

Support creating ajv bundle in Windows #206

sushant160185 opened this issue Jun 7, 2016 · 26 comments

Comments

@sushant160185
Copy link

Hi,

While install ajv throug npm I'm getting error. Attached is the error log "npm-debug.txt"
npm-debug.txt

I was also not able to create separate UMD bundle for browser using npm run bundle script. Attached in the error log "npm-run-bundle-debug.txt" Is it required that I install ajv before creating the bundle?
npm-run-bundle-debug.txt

Let me know what could be the problem here.

Thanks.

@epoberezkin
Copy link
Member

Can't reproduce, although I tried with npm 3.9.3 (I used nvm to install, that's the latest it has), yours is 3.9.5

@epoberezkin
Copy link
Member

Ah, just noticed, you have windows...

@epoberezkin
Copy link
Member

Also, did you just 'npm install'ed or 'git clone'd and then installed?

@sushant160185
Copy link
Author

Yes. I'm trying it on windows.

I tried two ways. First downloaded the zip and copied in into file system and then tried npm install. Then also tried to git cloned and then install, however the issue was same.

@epoberezkin
Copy link
Member

It all works on mac...

Can you at least install ajv as a dependency?

The only existing circular dependency, if that's what it is, is that ajv depends on gh-pages-generator that depends on ajv. gh-pages-generator is a dev dependency (although it makes no difference on mac, it works ok if it's a normal dependency as well)... Can you maybe try removing it from package.json and run npm install without it?

@ralphtheninja
Copy link

@sushant160185 Can you provide us with a package.json of your project so we can try and reproduce this?

@epoberezkin
Copy link
Member

@epoberezkin
Copy link
Member

@ralphtheninja Ah, sorry, got it :)

@epoberezkin
Copy link
Member

As I understood, @sushant160185 did just the following:

git clone git@github.com:epoberezkin/ajv.git
cd ajv
npm install

So ajv is not a dependency, it was installed separately.

@sushant160185 is it correct?

@ralphtheninja
Copy link

Works well on linux as well. I suspect something is fishy here ;)

@sushant160185
Copy link
Author

@epoberezkin Yes, all I did was create a clone of ajv (using git desktop), "cd ajv" and "npm install ajv" and I got this error. I haven't changed or added anything in the ajv repository. I'm trying it on windows 7 os.

@ralphtheninja package.json is part of the ajv repository. No changes done in that.

I'm new to this npm environment so if you can give me some steps on how should I do it on windows environment then it will be helpful for me.

Thanks.

@epoberezkin
Copy link
Member

Did you try removing gh-pages-generator from package.json before npm install?

@sushant160185
Copy link
Author

Yes, I did. Seems it still gave same exception. Attached is the log.
npm-debug.txt

@ralphtheninja
Copy link

I'm new to this npm environment so if you can give me some steps on how should I do it on windows environment then it will be helpful for me.

You shouldn't need to do anything special. Unfortunately I don't have access to a windows machine at home :/ I can try tomorrow.

@epoberezkin
Copy link
Member

@sushant160185 Can I ask what are you trying to do in general? To make some change in ajv?

@sushant160185
Copy link
Author

No, not to change anything in ajv. I wanted to try this in a simple browser based app. So at first I tried creating bundle from ajv package, however, "npm run build" script failed. I then tried to do installation first and then check the build process, however, that also failed.

In the meantime, I picked up the file from cdnjs site for my app so as such I'm not stuck but was just hoping that I should be able to install and/or create the bundle independently.

@epoberezkin
Copy link
Member

Bundle is included in npm package. If you make ajv a dependency in your app (npm install ajv --save), there will be a bundle in the folder node_modules/ajv/dist. Using CDN is also an option.

I still need to figure out what is wrong with npm install inside ajv in windows.

@blakeembrey
Copy link
Collaborator

It's not a bug, it's caused by the command you've tried to run. You don't want to do npm install ajv inside ajv - you can not install the module inside itself. If you're trying to use it locally, you can use npm install (no ajv) to install dependency and npm link to link it to other places. Most likely, you just want to install ajv inside your project - so you'd cd into your project and run npm install ajv there.

@sushant160185
Copy link
Author

Thanks @blakeembrey. This copied the ajv and other dependencies inside my project app with some warnings.
For the package creation for web ("npm run bundle" mentioned in the browser documentation section), what should I do since there is no bundle script in this copied folder. Although as @epoberezkin mentiond, it already has those files inside dist folder. Still how to create the ajv bundle for browser usage? Can you give me the steps?

@epoberezkin
Copy link
Member

The bundle shipped with ajv can be used as is - this is recommended.

If you really want to re-build you need:

git clone git@github.com:epoberezkin/ajv.git
cd ajv
npm install
npm run build
npm run bundle

@sushant160185
Copy link
Author

@epoberezkin Thanks. I ran these commands. Everything ran fine except npm run bundle, which gave error

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

@blakeembrey
Copy link
Collaborator

Most likely because https://github.com/epoberezkin/ajv/blob/master/package.json#L21 isn't a Windows executable. I think if you change ./scripts/ to node script/ it will work on Windows.

@epoberezkin epoberezkin reopened this Jun 14, 2016
@sushant160185
Copy link
Author

@blakeembrey I made the changes however it still failed with following error.

ajv\scripts\bundle:9
name=$(./scripts/info $package name)
^
SyntaxError: Unexpected token .
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:456:3

@epoberezkin
Copy link
Member

@sushant160185 You have to fix lines 9-12 in bundle script in the same way.

@sushant160185
Copy link
Author

I did that as well. The error this time was:

ajv\scripts\bundle:9
name=$(node scripts/info $package name)
^^^^
SyntaxError: missing ) after argument list

@epoberezkin epoberezkin changed the title Refusing to install ajv as dependency of itself Support creating ajv bundle in Windows Jul 9, 2016
@epoberezkin
Copy link
Member

in 4.11.5

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

No branches or pull requests

4 participants