keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.63k stars 2.21k forks source link

Error building files on fresh install #1514

Closed ghost closed 8 years ago

ghost commented 9 years ago

I'm getting these errors with a fresh install of keystone with yeoman. What could be causing them?

2015-07-07 14:07:42 error building views/home.js: Parsing file /usr/local/lib/node_modules/keystone/admin/src/views/home.js: Unexpected token (11:4) 2015-07-07 14:07:43 error building views/item.js: Parsing file /usr/local/lib/node_modules/keystone/admin/src/views/item.js: Unexpected token (46:9) 2015-07-07 14:07:43 error building views/list.js: Parsing file /usr/local/lib/node_modules/keystone/admin/src/views/list.js: Unexpected token (25:4) 2015-07-07 14:07:66 error building fields.js:

morenoh149 commented 9 years ago

can you paste your home and token.js

ghost commented 9 years ago

Here is my home.js file http://pastebin.com/PEes5TpD

I'm unable to locate token.js, can you specify the path?

morenoh149 commented 9 years ago

sorry meant item.js and list.js

ghost commented 9 years ago

/usr/local/lib/node_modules/keystone/admin/src/views/item.js http://pastebin.com/W1xherTv

/usr/local/lib/node_modules/keystone/admin/src/views/list.js http://pastebin.com/Hu6ub8ER

tomasbillborn commented 9 years ago

I got these errors all of a sudden and could fix them by

https://github.com/keystonejs/keystone/issues/1411

if you update to creynders answer

var bundles = { fields: browserify('./fields.js', 'FieldTypes'), home: browserify('./views/home.js'), item: browserify('./views/item.js'), list: browserify('./views/list.js') };

if it is not obvious its the missing ./ in the path that creates the problem. I think its just / in keystone atm.

ghost commented 9 years ago

Just prepended './' to all of the bundle urls in /node_modules/keystone/admin/app/static.js. I'm getting the same issue.

http://pastebin.com/d6pmAGH1

edit: should this be done in my local keystone module?

ghost commented 9 years ago

Is this the same as creynders answer? The error I'm getting is "Parsing file : Unexpected token", the error message in the issue you linked is "Cannot find module". Still haven't gotten it to work, tried both the './' and the '../src/' paths

tomasbillborn commented 9 years ago

It solves the error with the paths for the items above being incorrect, exactly what the token issue is I can't help you with. I got multiple errors trying to go with the yeoman set up. So I used the tutorial under "getting started" instead.

Rizato commented 9 years ago

In my case neither the ‘./‘ nor ‘../src/‘ options worked. I can run it locally, but when I push this up to an openshift instance I get these errors which break the admin UI.

I had the same issues on 0.3.12 back through 0.3.8.

My mistake, I reverted back to 0.3.8 and it worked just fine.

JedWatson commented 9 years ago

Looks like there are two issues being discussed here; one was related to resolving the path of the files, that should have been fixed in the latest release. The other is an issue where (it sounds like) browserify can't parse the files.

The parse error would indicate babel isn't being run successfully, that would cause browserify to choke on the ES6 / JSX syntax in the client-side files.

Can someone post some more specific debugging info on this? (environment, versions, etc) I can't replicate the problem at all locally. Also check the versions of babel and browserify that are being installed in the node_modules folder and let me know...

theolampert commented 9 years ago

Can confirm this happened to me upgrading my project from 0.3.10 to 0.3.12. I fixed it by blasting the node_modules folder and re-running npm install. As far as I can tell I had an older version of babel and/or browserify listed in my package.json.

Andreamsofcake commented 9 years ago

rm -r node_module and npm install did not fix the problem for me. Here are the versions: "name": "babelify", "version": "6.1.3", and "name": "browserify", "version": "10.2.6",

kfancy commented 9 years ago

Just to be thorough I'm going to re-post here since the other issue is closed....

Hi Team KJS

We are still encountering this error, it seems browserify is not properly transforming the JSX inside home.js, list.js, view.js, per freezer's original comment on this thread.

Problem appears to be that browserify is not properly transforming the files using jsx (reactify). The unexpected token is the inline jsx .

Applying update 0.0.1-admins... 2015-07-22 11:07:84 error building views/item.js: /Users/__/Code/package.json: Unexpected token < while parsing file: /Users/__/Code/my-app/node_modules/keystone/admin/src/views/item.js 2015-07-22 11:07:85 error building fields.js: /Users/__/Code/package.json: Unexpected token < while parsing file: /Users/__/Code/my-app/node_modules/keystone/admin/src/fields.js 2015-07-22 11:07:86 error building views/home.js: /Users/__/Code/package.json: Unexpected token < while parsing file: /Users/__/Code/my-app/node_modules/keystone/admin/src/views/home.js 2015-07-22 11:07:86 error building views/list.js: /Users/__/Code/package.json: Unexpected token < while parsing file: /Users/__/Code/my-app/node_modules/keystone/admin/src/views/list.js

We have done a complete uninstall-reinstall of nodejs, dumped local node_modules folders, and still encounter this error.

On: OSX Yosemite, 10.10.4 (latest version)

kfancy commented 9 years ago

OK after much pain and suffering, managed to route around this issue temporarily by:

  1. fork keystone
  2. edit package.json to roll back and lock babel to "5.6.7" version (was previously "^5.6.7")

There appears to be problems internally at babel-core, where the latest parser is choking on JSX.

@JedWatson any chance in updating the package directly in keystonejs to set babel, so we're not working from a fork?

davibe commented 9 years ago

I got the same problem with latest release 0.3.14 -- this breaks keystone admin interface entirely

Seems to be same as https://github.com/keystonejs/keystone/issues/1411

My dockerfile may help reproduce this

FROM phusion/baseimage:0.9.12
CMD ["/sbin/my_init"]
ENV HOME /
ENV NODE_PATH /usr/local/lib/node_modules
WORKDIR /work

RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
RUN apt-get update && apt-get install -y \
  --no-install-recommends \
  -o Dpkg::Options::="--force-confdef" \
  -o Dpkg::Options::="--force-confold" \
  nodejs build-essential git-core python
RUN npm install -g npm
RUN npm install -g keystone

ADD ./package.json /work/package.json
# keystone is global or it would be slow to reainstall
# each time
RUN npm link keystone && npm install .
ADD . /work
RUN npm install .

EXPOSE 3000
ninjasort commented 9 years ago

Have you tried running browserify with the --debug option to see what the parse error might be?

kfancy commented 9 years ago

TL;DR working 0.4.0-alpha fork, that skirts the babel build problems: https://github.com/agarmy/keystone

also includes a method to skip application of a global "model prefix", for those interested.

What happened:

It's something to do with babel-*, but alas only on some systems. My mac laptop, works fine. my co-developer's laptop, fails with errors like:

2015-09-04 14:09:38 error building fields.js: /Users/__/Code/package.json: Error while parsing JSON - Unexpected token < while parsing file: /Users/__/Code/MY_APP /node_modules/keystone/admin/src/fields.js 2015-09-04 14:09:40 error building views/home.js: /Users/__/Code/package.json: Error while parsing JSON - Unexpected token < while parsing file: /Users/__/Code/MY_APP /node_modules/keystone/admin/src/views/home.js 2015-09-04 14:09:41 error building views/signin.js: /Users/__/Code/package.json: Error while parsing JSON - Unexpected token < while parsing file: /Users/__/Code/MY_APP /node_modules/keystone/admin/src/views/signin.js 2015-09-04 14:09:41 error building views/item.js: /Users/__/Code/package.json: Error while parsing JSON - Unexpected token < while parsing file: /Users/__/Code/MY_APP /node_modules/keystone/admin/src/views/item.js 2015-09-04 14:09:42 error building views/list.js: /Users/__/Code/package.json: Error while parsing JSON - Unexpected token < while parsing file: /Users/__/Code/MY_APP /node_modules/keystone/admin/src/views/list.js

No idea how to fix, other than babel rollback:

  1. Fork keystone
  2. update package.json with: "babel-core": "5.6.7", "babel-plugin-object-assign": "^1.2.0", "babelify": "^6.1.2",
  3. update your local app to point to your fork
  4. npm uninstall then re-install keystone

... which exposed a couple of other problems due to the "..." splat syntax not really supported by older babel.

2015-09-04 15:09:22 error building views/list.js: /Users/_/work/code_development/MY_APP/nodemodules/keystone/admin/src/views/list.js: Unexpected token (22:3) while parsing file: /Users//work/code_development/MY_APP/node_modules/keystone/admin/src/views/list.js

however I managed to fix them by rolling back the splat to use a different method to build objects.

creynders commented 9 years ago

@kfancy Just an FYI, if you want to pindown/override a package's versions you can use npm shrinkwrap. In your project cd to node_modules/keystone, then install the specific versions of the problematic packages. Next cd back to your project and run npm shrinkwrap, it will create a npm-shrinkwrap.json file, with all package versions locked down to the ones installed. If you commit this file to your repo, anybody who does a npm install of your project will get those exact package versions installed.

davibe commented 9 years ago

i figured out that this happens if you have keystone installed globally and then you link it in your project. If you have the keystone package installed locally it does not happen (for me)

klavs commented 9 years ago

Same here. Works localy (where I did npm install keystone), but does not work on OpenShift, where, I guess, it gets installed globaly.

mxstbr commented 8 years ago

We're closing all questions and support requests to keep the issue tracker unpolluted. Please ask this question on Stackoverflow or Gitter instead!