0

I have created a new node (MERN) app on my mac osx. Im learning (from rails).

I don't know why, but whilst I do have a package.json file, I cannot generate a node_modules folder. I have tried all of the suggested answers in this post.

When I go to the terminal and test:

ls node_modules

I get a long list of all the modules listed in my package.json (but no node modules folder in my app file in atom).

That list includes all of my babel modules.

When I try to start the app, I get an error that arises out of my using import statements instead of require (which I should be able to do if babel were working).

node server.js
/Users/mr_may/server.js:1
(function (exports, require, module, __filename, __dirname) { import express from 'express';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:390:7)
    at startup (bootstrap_node.js:150:9)

Does anyone know how to configure a new node app so that it generates the node modules folder? Apart from the post above, I can't find any suggestions on how to work through this problem. The answers in the post linked above haven't worked.

Mel
  • 2,481
  • 26
  • 113
  • 273

1 Answers1

0

hi you may want to make sure you are in the directory of your folder e.g.

cd Desktop/My_Project

The safest way is the then run npm init get all the required things fill out and run npm install --save babel-core at this point you should be able to see the node_modules folder found in "Desktop/My_Project/node_modules"

Try this out and hope this helps :D

Malcolm
  • 289
  • 2
  • 9