{
"name": "package.js",
"version": "1.0.0",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "babel-watch server.js"
},
"dependencies": {
"babel-core": "^6.26.3",
"expo": "^26.0.0",
"react": "16.3.0-alpha.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-react": "^6.24.1",
"babel-watch": "^2.0.7"
},
"depencies": {
"apollo-server-express": "^1.3.2",
"express": "^4.16.2",
"graphql": "^0.13.0",
"graphql-tools": "^2.20.2"
}
}
执行npm run dev后显示的错误。错误日志如下。我对GraphQL,Apollo和Angular相当陌生。
20 error code ELIFECYCLE
21 error errno 1
22 error backend@1.0.0 dev: `babel-watch server.js`
22 error Exit status 1
23 error Failed at the backend@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
如果我缺少任何其他文件,请随时在评论中提问。
Server.Js
import express from 'express';
import bodyParser from 'body-parser';
import { graphqlExpress } from 'apollo-server-express';
const app = express();
app.get('/', (req, res) => res.send('Hello World'));
app.listen(4000, () => console.log('Express server running on port 4000'));
答案 0 :(得分:0)
似乎缺少软件包babel-preset-env
,只需与npm install babel-preset-env
一起安装。
如果这不能解决问题,可能是因为您在另一个命令行中有另一个npm
实例。检查同一端口中是否还有其他npm在运行。
还要删除node_modules
并清理缓存npm cache clean
,然后重新安装节点模块(npm install
)。