Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Alejandro Bautista Ramos
Alejandro Bautista Ramos
3,419 Points

Syntax Error: Unexpected token ...

When I try to run the command npm install on my terminal I receive:

Syntax Error: Unexpected token ... at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:373:25) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/Users/alexbr/Downloads/photo_blog/config/release.config.js:5:22) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10)

I am using a MAC OS system and I am using the Visual Studio Code editor but not the terminal from it. How can I fix this problem?

Dan Sabin
Dan Sabin
Courses Plus Student 1,909 Points

What version of the following do you have:

  • nodejs
  • npm

What package are you npm installing or what does your package.json look like? Also generally in the errors you get back it will tell you which package is failing to install (or check the npmdebug file that gets created at the root of your project). Include more of this information otherwise it's very hard to help.

2 Answers

Alejandro Bautista Ramos
Alejandro Bautista Ramos
3,419 Points

Dan, thank you very much for your reply. I have attached the log file from npm-debug. Hope this can help to track better the problem.

0 info it worked if it ends with ok

1 verbose cli [ '/usr/local/Cellar/node4-lts/4.4.4/bin/node',

1 verbose cli '/usr/local/bin/npm',

1 verbose cli 'run',

1 verbose cli 'build' ]

2 info using npm@3.8.6

3 info using node@v4.4.4

4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]

5 info lifecycle photoblog@~prebuild: photoblog@

6 silly lifecycle photoblog@~prebuild: no script for prebuild, continuing

7 info lifecycle photoblog@~build: photoblog@

8 verbose lifecycle photoblog@~build: unsafe-perm in lifecycle true

9 verbose lifecycle photoblog@~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/alexbr/Downloads/photo_blog/node_modules/.bin:/usr/local/Cellar/node4-lts/4.4.4/bin:/Users/alexbr/perl5/perlbrew/bin:/Users/alexbr/perl5/perlbrew/perls/perl-5.16.0 /bin:/Library/Frameworks/Python.framework/Versions/3.3/bin:/usr/local/bin:/Library/ Frameworks/Python.framework/Versions/3.3/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin: /opt/X11/bin:/bin:/sbin:/usr/bin:/usr/sbin:/Users/alexbr/.rvm/bin:/Users/alexbr/.rvm/bin

10 verbose lifecycle photoblog@~build: CWD: /Users/alexbr/Downloads/photo_blog

11 silly lifecycle photoblog@~build: Args: [ '-c', 'webpack' ]

12 silly lifecycle photoblog@~build: Returned: code: 1 signal: null

13 info lifecycle photoblog@~build: Failed to exec build script

14 verbose stack Error: photoblog@ build: webpack

14 verbose stack Exit status 1

14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:239:16)

14 verbose stack at emitTwo (events.js:87:13)

14 verbose stack at EventEmitter.emit (events.js:172:7)

14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)

14 verbose stack at emitTwo (events.js:87:13)

14 verbose stack at ChildProcess.emit (events.js:172:7)

14 verbose stack at maybeClose (internal/child_process.js:827:16)

14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

15 verbose pkgid photoblog@

16 verbose cwd /Users/alexbr/Downloads/photo_blog

17 error Darwin 15.6.0

18 error argv "/usr/local/Cellar/node4-lts/4.4.4/bin/node" "/usr/local/bin/npm" "run" "build"

19 error node v4.4.4

20 error npm v3.8.6

21 error code ELIFECYCLE

22 error photoblog@ build: webpack

22 error Exit status 1

23 error Failed at the photoblog@ build script 'webpack'.

23 error Make sure you have the latest version of node.js and npm installed.

23 error If you do, this is most likely a problem with the photoblog package,

23 error not with npm itself.

23 error Tell the author that this fails on your system:

23 error webpack

23 error You can get information on how to open an issue for this project with:

23 error npm bugs photoblog

23 error Or if that isn't available, you can get their info via:

23 error npm owner ls photoblog

23 error There is likely additional logging output above.

24 verbose exit [ 1, true ]

Dan Sabin
PLUS
Dan Sabin
Courses Plus Student 1,909 Points

I'd recommend updating your current version of node. My guess is that the current version of some of the packages are requiring that you be on node 6.x.x and you're on an older 4.x.x

Try updating node to the latest LTS version which would be 6.10.2. You can use nvm to manage your node version. It's similar to rvm which I see you have installed. Checkout out the nvm instructions here: https://github.com/creationix/nvm#installation