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

lasso-express throwing syntax error on start #18

Open
Aerlin opened this issue Sep 1, 2021 · 1 comment
Open

lasso-express throwing syntax error on start #18

Aerlin opened this issue Sep 1, 2021 · 1 comment

Comments

@Aerlin
Copy link

Aerlin commented Sep 1, 2021

Running npm run dev works as expected, but npm run start is throwing an error.

> NODE_ENV=production node -r @babel/register -r marko/node-require src/server.js

/home/xxx/projects/lasso-express/node_modules/marko/dist/node-require/index.js:3
const complain;
      ^^^^^^^^

SyntaxError: Missing initializer in const declaration
    at wrapSafe (internal/modules/cjs/loader.js:988:16)
    at Module._compile (internal/modules/cjs/loader.js:1036:27)
    at Module._compile (/home/xxx/projects/lasso-express/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Object.newLoader [as .js] (/home/xxx/projects/lasso-express/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/home/xxx/projects/lasso-express/node_modules/marko/node-require.js:7:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lasso-express@1.0.0 start: `NODE_ENV=production node -r @babel/register -r marko/node-require src/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lasso-express@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/xxx/.npm/_logs/2021-09-01T05_55_58_610Z-debug.log

Here's the log that npm gave.

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/home/xxx/.nvm/versions/node/v14.17.6/bin/node',
1 verbose cli   '/home/xxx/.nvm/versions/node/v14.17.6/bin/npm',
1 verbose cli   'run',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.15
3 info using node@v14.17.6
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle lasso-express@1.0.0~prestart: lasso-express@1.0.0
6 info lifecycle lasso-express@1.0.0~start: lasso-express@1.0.0
7 verbose lifecycle lasso-express@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle lasso-express@1.0.0~start: PATH: /home/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/xxx/projects/lasso-express/node_modules/.bin:/home/xxx/.nvm/versions/node/v14.17.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
9 verbose lifecycle lasso-express@1.0.0~start: CWD: /home/xxx/projects/lasso-express
10 silly lifecycle lasso-express@1.0.0~start: Args: [
10 silly lifecycle   '-c',
10 silly lifecycle   'NODE_ENV=production node -r @babel/register -r marko/node-require src/server.js'
10 silly lifecycle ]
11 silly lifecycle lasso-express@1.0.0~start: Returned: code: 1  signal: null
12 info lifecycle lasso-express@1.0.0~start: Failed to exec start script
13 verbose stack Error: lasso-express@1.0.0 start: `NODE_ENV=production node -r @babel/register -r marko/node-require src/server.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/home/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/home/xxx/.nvm/versions/node/v14.17.6/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid lasso-express@1.0.0
15 verbose cwd /home/xxx/projects/lasso-express
16 verbose Linux 4.19.0-12-amd64
17 verbose argv "/home/xxx/.nvm/versions/node/v14.17.6/bin/node" "/home/xxx/.nvm/versions/node/v14.17.6/bin/npm" "run" "start"
18 verbose node v14.17.6
19 verbose npm  v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error lasso-express@1.0.0 start: `NODE_ENV=production node -r @babel/register -r marko/node-require src/server.js`
22 error Exit status 1
23 error Failed at the lasso-express@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
@smazyck2
Copy link

The reason for this error is that the "start" script is attempting to set an environment variable named 'NODE_ENV' using Linux-style scripting. If you are running the example on a Windows machine, the script will cause an error.

Specifically, the phrase "NODE_ENV=production" from the 'package.json' file is causing the error. The best way to resolve the problem universally is to create a separate file named ".env", then move "NODE_ENV=production" text (without the quotes) into that file. After this, you can use an npm package called "dotenv" to read the contents of your new env file to set the environment variable correctly.

https://www.npmjs.com/package/dotenv

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

No branches or pull requests

2 participants