Node.js应用程序未在生产环境中执行

时间:2018-09-15 10:16:58

标签: node.js sails.js

我是node.js的新手,因此无法正确理解错误。根据航行文件https://sailsjs.com/documentation/concepts/deployment

我正在尝试使用NODE_ENV=production node app.js执行sails.js应用程序,但它会引发一些错误。在npm run dev

的开发环境中正常工作时

现在在我的项目中已禁用的会话。现在,其他警告也已删除。

$ NODE_ENV=production node app
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
Aborted due to warnings.
Running "babel:dist" (babel) task
Warning: .tmp/public/js/sdk.js: 'with' in strict mode (22:780)
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to resume watching for changes to assets:
error:      CTRL+C, then `sails lift`
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error:  *-> Are "grunt" and any custom Grunt plugins you're using installed in this project?
error:      Run `npm install` if you're not sure.
error:
error:  *-> You might have a typo in one of your LESS files, etc.
error:
error:  *-> Or maybe you don't have permissions to access the `.tmp` directory?
error:      e.g., `C:\xampp\htdocs\soochna_sails\.tmp` ?
error:
error:      If you think this might be the case, try running:
error:      sudo chown -R YOUR_COMPUTER_USER_NAME C:\xampp\htdocs\soochna_sails\.tmp
error:
error:  *-> If you're still unsure, drop by https://sailsjs.com/support.

我的package.json文件是

"description": "a Sails application",
    "keywords": [],
    "dependencies": {
        "@sailshq/connect-redis": "^3.2.1",
        "@sailshq/lodash": "^3.10.3",
        "@sailshq/socket.io-redis": "^5.2.0",
        "async": "2.0.1",
        "grunt": "1.0.1",
        "nodemon": "^1.17.5",
        "sails": "^1.0.2",
        "sails-hook-autoreload-extend": "^1.0.4",
        "sails-hook-grunt": "^3.0.2",
        "sails-hook-orm": "^2.0.0-16",
        "sails-hook-sockets": "^1.4.0",
        "sails-mysql": "1.0.0",
        "dropzone": "5.5.1"
    },
    "devDependencies": {
        "@sailshq/eslint": "^4.19.3"
    },
    "scripts": {
        "start": "NODE_ENV=production --ignore 'tmp/*' node app.js",
        "dev": "set NODE_ENV=development && nodemon --ignore 'tmp/*' app.js && exit 0",
        "test": "npm run lint && npm run custom-tests && echo 'Done.'",
        "lint": "eslint . --max-warnings=0 --report-unused-disable-directives && echo '✔  Your .js files look good.'",
        "custom-tests": "echo \"(No other custom tests yet.)\" && echo"
    },
    "main": "app.js",
    "repository": {
        "type": "git",
        "url": "git://github.com/xxxxxxx/test-project.git"
    },

    "license": "",
    "engines": {
        "node": ">=9.11"
    }

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我也经常遇到这个问题。这是有趣的部分:

  

错误:*->也许您没有访问.tmp目录的权限?   错误:例如C:\xampp\htdocs\soochna_sails\.tmp吗?   错误:   错误:如果您认为可能是这种情况,请尝试运行:   错误:sudo chown -R YOUR_COMPUTER_USER_NAME C:\ xampp \ htdocs \ soochna_sails.tmp

您显然是在Windows上托管,因此在生产模式下启动应用程序之前,请尝试使.tmp文件夹具有写访问性,或者手动将其删除。