"name": "javascript-development-environment",
"version": "1.0.0",
"description": "CS 235 package.json file for programming projects",
"scripts": {
"prestart": "babel-node buildScripts/startMessage.js",
"redditImgGet": "babel-node buildScripts/srcReddit.js",
"install": "npm install",
"start":"npm-run-all --parallel security-check open:src",
"security-check": "nsp check",
"open:src": "babel-node buildScripts/srcServer.js"
},
目前我是package.json
。我试图调用从 reddit 获取图像的脚本。 srcReddit.js
的内部如下所示:
var snoowrap = require('snoowrap');
console.log("Starting Reddit Image Fetcher");
const otherRequester = new snoowrap({
userAgent: navigator.userAgent,
clientId: 'Cf8kGqDSuT17xw',
clientSecret: 'DDmMslUwMJW1ZM5JTc07zJDpC8k',
username: 'sharan100',
password: 'Magewindu100'
});
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
r.getHot().map(post => post.title).then(console.log);
console.log("Ending Reddit Image Fetcher");
为此,我使用了snoowrap的包装器reddit API。现在当我做npm start
时,我出于某种原因得到以下结果:
不知道为什么console.log
消息没有出现。有谁知道为什么?
答案 0 :(得分:1)
npm start
运行start
任务,它似乎在任何时候都没有引用redditImgGet
任务。
我认为您应该将start
任务更改为
npm-run-all --parallel security-check open:src redditImgGet
或者直接运行任务
npm run redditImgGet
否则,我看不到srcReddit
文件在哪里记录任何内容。