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

Node cannot find module 'gonzales-pe' #245

Open
tbassetto opened this issue Nov 14, 2016 · 10 comments
Open

Node cannot find module 'gonzales-pe' #245

tbassetto opened this issue Nov 14, 2016 · 10 comments

Comments

@tbassetto
Copy link

I have followed the instructions in the README to install parser as a project dependency:

npm install --save git://github.com/tonyganch/gonzales-pe.git#dev

And I am using it like this:

const fs = require('fs');
const gonzales = require('gonzales-pe');

const content = fs.readFileSync('app.15b3fb9686901533f471.css', 'utf-8');
const parseTree = gonzales.parse(content);

But I get:

Error: Cannot find module 'gonzales-pe'

I suspect it's because package.json has "./lib/gonzales" for the "main" property, which doesn't exist!

How to use the parser in a node project then?

@DanPurdy
Copy link
Collaborator

DanPurdy commented Nov 15, 2016

Because you installed it directly from Github I believe you'll have to build it before you can use the package. Might not be correct but you can try moving into the gonzales-pe folder and running

npm run build

see here and then try using the package again.

@tbassetto
Copy link
Author

Hey. I have installed the package again using npm install --save gonzales-pe and it works as expected. Is it an official package published on npm? If yes it should probably used in the README instead of recommending the installation via GitHub.

@DanPurdy
Copy link
Collaborator

DanPurdy commented Nov 16, 2016

Yes it is it's just that there is a build step involved. Before publishing to NPM a build step is invoked and that output is pushed to NPM whereas obvously targeting Github means that pre-publish hasn't happened.

I agree that it's probably a good idea to document this in the Readme though.

@tonyganch
Copy link
Owner

Hey guys! There was a postinstall script that allowed installing straight from GitHub without any additional build steps, but there was a problem reported on Windows platform and I disabled it:
f335711

I completely forgot about it since then and never restored it back. I'll take a look after v4.0 release.

@tonyganch
Copy link
Owner

Related issue: #149

@tonyganch
Copy link
Owner

@tbassetto, could you please test installing gonzales-pe from GitHub once again? I've added postinstall script, tested it locally and both Travis and Appveyor look okay, but I'm not 100% sure about it.

@DanPurdy
Copy link
Collaborator

If it's a purely bash script it won't be suitable.. Bash might work on the latest windows but for legacy it will fail.. If we want to keep it pure we should look at node postinstall scripts

@bgriffith
Copy link
Collaborator

bgriffith commented Nov 18, 2016

Talking of which - after updating the dep to v4 getting;

> gonzales-pe@4.0.0 postinstall /home/travis/build/sasstools/sass-lint/node_modules/gonzales-pe
> bash ./scripts/postinstall.sh
bash: ./scripts/postinstall.sh: No such file or directory

https://travis-ci.org/sasstools/sass-lint/jobs/176886355

@tonyganch
Copy link
Owner

Thanks for the news, guys. I've removed the script, released 4.0.1 without it and will just update docs, so we will live without GitHub installations.

@jdalton
Copy link
Contributor

jdalton commented Mar 28, 2019

I can change this to a prepare script so that gonzales-pe will work for git: installs.

@jdalton jdalton self-assigned this Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants